1
2
3
0
4) Which statements if inserted at the location indicated would cause compilation error
public class test10
{
static void disp(final int a,int b,final int[]c,int[]d)
{
//Insert Here
}
public static void main(String args[])
{
int a=0;
final int b=1;
int[] c={2};
final int[]d={3};
disp(a,b,c,d);
}
}
Select the two Correct answers
a) b++;
b) a++;
c) b=a;
d) c[0]=20;
e) c=d;
f) d[0]++;
5) After execution of the following code fragment, what are the values of the variable x, a and b?
int x, a = 6, b = 7;
x = a++ + b++;
1. x=15,a=7,b=8
2. x=15,a=6,b=7
3. x=13,a=7,b=8
4. x=13,a=6,b=7
7) Which of the following is the correct syntax for suggesting the JVM performs garbage collection.
1. System.free ();
2. System.setGarbageCollection () ;
3. System.out.get () ;
4. System.gc ();
2. /0
3. zero
4. null
11) Given the following class,which statements can be inserted at position 1 without causing a
compilation error?
public class test1
{
int a;
int b=0;
static int c;
public void disp()
{
int d;
int e=0;
// Position 1
}
}
Select 4 correct answers
a) a++ b) b++ c) c++ d) d++ e) e++
12) What will be the result of attempting to compile and run the following code?
public class test3
{
static int a;
int b;
public test3()
{
int c;
c=a;
a++;
b+=c;
}
public static void main(String args[])
{
new test3();
}
}
Select the one correct answer
a) The code will fail to compile since the constructor is trying to access static members
b) The code will fail to compile since the constructor is trying to use static field a
before it has been initialized.
c) The code will fail to compile since the constructor is trying to use static field b
before it has been initialized.
d) The code will fail to compile since the constructor is trying to use static field c
before it has been initialized.
e) The code will compile and run without any problems.
13) What will be the output ?
public class test4
{
public static void main(String args[])
{
System.out.println(9^2);
}
}
a) 81
b) 7
c) 11 d) 0 e) false
14) Which declarations of main() method are valid in order to start the execution of an
application?
Select two correct answers
a) public void main(String args[])
b) public void static main(String args[])
c) public static main(String args[])
d) final public static void main(String [] args)
e) public static void main(String args[])
15) which statements are true about casting and conversion ?
Select the three correct answers
a) Conversion from int to long does not need a cast
b) Conversion from byte to short does not need a cast
c) Conversion from float to long does not need a cast
d) Conversion from short to char does not need a cast
e) Conversion from boolean to int using a cast is not possible