SET-1
1) What is the output of following program[Java files]
import java.io.*
class filesinputoutput
{
public static void
main(strings args[])
{
InputStream obj = new FileInputStream(“inputoutput.java”);
System.out.print(obj.available());
}
}
a)true
b) prints number of bytes in file
c) false
d)prints number of characters in the
file
Ans: b
Obj.available() returns number of
bytes
2)What is the output of this c code [datatypes]
#include<stdio.h>
int main()
{
double b=3&&5&4%3;
printf(“%lf”,b);
}
a) 4.000000
b) 5.000000
c) 1.000000
d) 3.000000
Ans: c
3)What is the output of this c code [datatypes]
#include<stdio.h>
Static int x=5;
int main()
{
X=9;
{
Int x=4;
}
Printf(“%d”,x);
}
a) 4
b) 5
c) 0
d) 9
Ans: d
4) Which of these methods can be used ot increase the capacity
of ArrayList object manually[Java Arrays]
a) Capacity()
b) increase Capcacity()
c) increasecapacity()
d) ensuerCapacity()
Ans:d
When we add an element the capacity
of ArrayList object increases automatically,but we can increase it manually to
specified length x by using function ensureCapacity(x).
5)Suppose there are 11 items in sorted order in an array. How
many searches are required on the average, if binary search is employed and all
searches are successful in finding the item.[Binary Search]
a)3.26
b)3.00
c)3.59
d)3.42
Ans:b
6)What is the major data structure use in network data
model?[DS]
a)stack
b) Graphs
c) Trees
d) List
Ans:b
7) What is the output of the following code[storage classes]
#include<stdio.h>
int i;
int main()
{
extern int I;
if (i==0)
printf(“Scope Rules”);
}
a) Nothing as I value is not zero being automatic variable
b) Compile time error due to multiple declaration
c) Scope Rules
d) Compile time error due to not defining type in statement
extern i
Ans: c
As I is global variable its default
value is zero so if condition is true and printf statement get executed.
8)With x=0, which of the following are legal lines of java
code for changing the
Value of x to 1?[operators]
1) x++;
2) x=x+1;
3) x+=1;
4) x=+1;
a) 3&2
b) 1,2 &3
c) 1&4
d) 1,2,3 & 4
Ans: d
9)What is the output of this C code
int x;
void main()
{
printf(“%d”,x);
}
a) Junk value
b) 0
c) Run time error
d) Undefined
Ans:0
As x is global variable its default
value 0 is printed
10)The maximum number if times the decrease key operation
performed in Dijkstra’s algorithm will be equal to [Algorithms]
a) Number if edges-1
b) Number of vertices-1
c) Total number of edges
d) Total number of vertices
Ans:c
--------------------------------------------------------------------------------------------------------------------------
Coding Question:
Q) /*m<n;0<m<999;n<=999
Write a program to smartly affix
zeroes
Ex:1
5 10
Output:
05 06 07 09 10
Ex:2
9 100
Output:
009 010 011........100
Ex:3
1 5
Output:
1 2 3 4 5
*/
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,i,d1,d2,t,k;
scanf("%d%d",&a,&b);
d1=log10(b)+1;
for(i=a;i<=b;i++)
{
d2=log10(i)+1;
t=d1-d2;
for(k=1;k<=t;k++)
printf("0");
printf("%d ",i);
}
return 0;
}
-------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment