1.
main()
{
int i=10;
printf("%d %d",i+++i,i---i);
}
1)compiler error 2)21 1 3)19 1 4)22 1
2.
main()
{
int u,v,t;
u=35;
v=28;
while(v!=0)
{
t=u%v;
u=v;
v=t;
}
printf("%d\n",u);
}
1)28 2)7 3)infinite loop 4)35
3.
main()
{
int array[10];
printf("%p %u %x %X",array,array,&array,&(&array));
}
1)error 2)ffcc 65484 FFCC FFCC
3)ffcc 65484 ffcc FFCC 4)FFCC 65484 ffcc FFCC
4.
#define PRINTX printf("%d\n",x)
main()
{
int x=2,y,z;
x*=3 + 2; PRINTX;
x*= y = z = 4; PRINTX;
x = y == z; PRINTX;
x==(y=z); PRINTX;
}
1)8 32 1 1 2)10 40 1 1 3)8 32 1 4 4)10 40 1 4
5.
main()
{
int i=10;
for(;i-->5;i=(i<5?i:i-1))
printf("\n%d",i);
}
1)9 7 2)9 3)9 7 5 4)9 7 5 3
6.
int func(int i)
{
if(i==0)
return 1;
else
return (i/func(i-1));
}
main()
{
int i=4;
printf("\n%d",func(i));
}
1)4 2)1 3)error:divide by zero 4)no output
7.
main()
{
int x=10,y,z;
z=y=x;
y-=x--;
z-=x--;
x-=--x-x--;
printf("%d %d %d\n",x,y,z);
z-= -x-- - --y;
printf("%d",z);
}
1)7,0,1,7 2)6,0,1,6 3)7,1,2,7 4)7,1,2,9
8.
#define A 100
#include
main()
{
printf("%d",++A);
}
1)101 2)100 3)error 4)66
9.
main()
{
int i;
for(i=0;i<5;(++i)+1)
printf("%d ",i);
}
1)0,1,2,3,4 2)0,2,4 3)0,1,2,4 4)0,1,4
10.
#define sqr(x) (x)*x
main()
{
int a,b=3;
a=sqr(b+1);
printf("%d",a);
}
1)7 2)13 3)9 4)garbage value
11.
main()
{
char a= 'A';
if( (a=='Z')||( (a='L')&&( a=='A')))
a=a;
printf("%c",a);
}
1)A 2)no output 3)L 4)garbage value
12.
int f(int n);
int f(int n)
{
int i;
static int j=0;
for(i =1;i<=n;i++)
f(n-i);
j++;
return j;
}
main()
{
int j=f(7);
printf("j=%d",j);
}
1) 128 2)127 3)255 4)256
13.
void main()
{
char a[5] = "abcd";
int b = 3;
printf("%c\n",a[b]);
printf("%c\n",((char *) b)[(int) a]);
}
1)d,b 2)d,d 3)error 4)d,garbage value
14.
#define colums 4
#define rows 3
main()
{
int i,j,k;
int a[rows][colums]={1,2,3,4,5,6,7,8,9,10,11,12};
i=j=k=99;
for(i=0;i
for(j=0;j
if(a[k][j]
k=a[i][j];
printf("\n%d\n",k);
}
1)garbage value 2)4 3)1 4)99
15.
main()
{
char c1;
int i=0;
c1='a';
while(c1>='a' && c1 <='z')
{
c1++;
i++;
}
printf("\n%d",i);
}
1)error 2)26 3)25 4)0
16.
#define mydef define
#mydef MAX 10
main()
{
printf("%d",MAX*MAX);
}
1)error 2)100 3)10 4)50
17.
main()
{
int binary1,binary2;
binary1 =0100;
binary2=0111;
printf("%d",binary1+binary2);
}
1)1011 2)211 3)137 4)118
18.
#define pxx(a,v) printf("%d",a##v)
main()
{
int x1=12,x2=24,x3=35;
pxx(x,1);
pxx(x,2);
pxx(x,2+1);
}
1)12,24,25 2)12,24,35 3)12,24,14 4)none of these
19.
main()
{
char *name="ITCENTRE";
name++;
printf("%s",++name);
++name;
if(name[2]=='T')
printf("\t YES");
else
printf("\t NO");
}
1)CENTER,YES 2)ERROR 3)ITCENTER,NO 4)ITCENTER,YES
20.
main()
{
#ifdef A
int a=10;
#else
int a=20;
#endif
int b=20;
printf("\n%d",a+b);
}
1)40 2)30 3)20 4)garbage value
21.
Which of the following is the correct syntax for suggesting that the JVM performs garbage collection
1)System.free();
2)System.memory.gc();
3)System.gc();
4)System.callGc();
22.
What is the result of invoking the method substring(2, 4) on the string "example"?
1)am 2)amp 3)xam 4)xa
23.
What is the code name of Java 5.0 during its development?
1)Oak 2)Tiger 3)Dolphin 4)Sun
24.
What is the full form of ANSI?
1)American National Specified Identifiers
2)American National Specified Integration
3)American National Standard identifiers
4)American National Standard Institute
25.
main() {
char s1[] = "Hagrid";
char s2[] = "Hagrid";
if (s1==s2)
printf ("Same");
else
printf ("Different");
}
1)same 2)different 3)error 4)no output
Answers:
3
2
4
2
3
1
2
3
1
2
3
1
2
3
2
1
3
1
1
1
3
1
2
4
2
No comments:
Post a Comment