1) char * ptr = “Hello”;
sizeof(ptr) = ?
2) char obj[10][20][30];
sizeof(obj) = ?
3) char c = 127; c = c + 10;
Which of the following is true?
4) double a = 5/10*2.0;
a = ?
5) int a = 2|1; //Bitwise OR operation
a = ?
6) int a = 3^1; //Bitwise XOR operation
a = ?
7) #include <iostream.h>
int main()
{
int a = 5;
{int a = 6;cout<<a;}
return 0;
}
What is the output of the above program?
8) char *p, z;
The datatype of z is
9) typedef void (*FN)(int);
void f1(int);
void * f2(int);
FN abc = f1; //Line1
FN abc = f2; //Line2
FN abc = &f1; //Line3
FN abc = &f2; //Line4
Which of the above lines will compile
10) #include <iostream.h>
int f() {static int a = 0;a = a – 1; return a;}
int main() {cout<<f()*f()*f()*f();return 0;}
The output of the above program is
11) int a = 1;
switch(a)
{
case 0: a++;
case 1: a = 3;
case 2: a++;
}
a = ?
12) #include <iostream.h> int main()
{char *p;strcpy(p,”Hello”)<<p<<3;return 0;}
The output of the above program will be
13) 13) class A{public void print(){System.out.print(“A”);}},
class B extends A{public void print(){System.out.print(“B”);}};
B a = new A();
What will a.print() print ?
14) class A{public static void print(){System.out.print(“A”);}},
class B extends A{public static void print(){System.out.print(“B”);}};
A a = new B();
What will a.print() print ?
15) x is an integer and x > 0. If (x & (x – 1)) == 0,
what can be said to be certainly true of x?
16) int foo(int a){ return a++ * ++a; } What’s the result of foo(5) ?
17) void incr(int a) { a++; }; int[] a = {2, 5}; incr(a[0]); a[0] = ?
18) int a = 5, b = a >> 1, c = b >> 2; // right bit shift operation b, c = ?
19) Object o = null;
try { System.err.println(o.toString()); }
catch ( Exception e ) { System.err.println(“Ex”);}
catch ( NullPointerException e) { System.err.println(“NPEx”);}
What’ll this print ?
20) int i = 1; try{ i++; throw new Exception();} catch (Exception ex ) { i++; throw ex;} finally{ i++; System.out.print(i)}; What will this print, if anything ?