Submitted by c-admin on Tue, 05/28/2019 - 04:46
What will be the output when the following class is compiled and run?
class ScopeTest{
static int x = 5;
public static void main(String[] args){
int x = ( x=3 ) * 4; // 1
System.out.println(x);
}
}
Select 1 option
A. It will not compile because line //1 cannot be parsed correctly.
B. It will not compile because x is used before initialization.
C. It will not compile because there is an ambiguous reference to x.
D. It will print 12.
E. It will print 3.
Submitted by c-admin on Tue, 05/28/2019 - 04:43
Given the following declarations, identify which statements will return true:
Integer i1 = 1;
Integer i2 = new Integer(1);
int i3 = 1;
Byte b1 = 1;
Long g1 = 1L;
Note: Although primitive wrapper classes are not explicitly mentioned in the exam objectives, we have seen some candidates get questions on this aspect of wrapper classes.
Select 2 options
A. i1 == i2
B. i1 == i3
C. i1 == b1
D. i1.equals(i2)
E. i1.equals(g1)
F. i1.equals(b1)
Submitted by c-admin on Tue, 05/28/2019 - 04:38
Which of the given lines can be inserted at //1 of the following program?
public class TestClass{
public static void main(String[] args){
short s = 9;
//1
}
}
Select 2 options
A. Short k = new Short(9); System.out.println(k instanceof Short);
B. System.out.println(s instanceof Short);
C. Short k = 9; System.out.println( k instanceof s);
D. int i = 9; System.out.println(s == i);
E. Boolean b = s instanceof Number;
F. Short k = 9; Integer i = 9; System.out.println(k == i);
G. Integer i = 9; System.out.println( s == i );
Submitted by c-admin on Tue, 05/28/2019 - 04:35
Given the following LOCs:
int rate = 10;
XXX amount = 1 - rate/100*1 - rate/100;
What can XXX be?
Select 1 option
A. only int or long
B. only long or double
C. only double
D. double or float
E. long or double but not int or float.
F. int, long, float or double
Submitted by c-admin on Tue, 05/28/2019 - 04:33
The following code snippet will not compile:
int i = 10;
System.out.println( i<20 ? out1() : out2() );
Assume that out1 and out2 have method signature: public void out1(); and public void out2();
Select 1 option
A. True
B. False
Pages