Submitted by c-admin on Tue, 05/28/2019 - 04:23
Consider the following lines of code:
Integer i = new Integer(42);
Long ln = new Long(42);
Double d = new Double(42.0);
Which of the following options are valid?
Select 3 options
A. i == ln;
B. ln == d;
C. i.equals(d);
D. d.equals(ln);
E. ln.equals(42);
Submitted by c-admin on Tue, 05/28/2019 - 04:20
Consider the following code:
public class Conversion{
public static void main(String[] args){
int i = 1234567890;
float f = i;
System.out.println(i - (int)f);
}
}
What will it print when run?
Select 1 option
A. It will print 0.
B. It will not print 0.
C. It will not compile.
D. It will throw an exception at runtime.
E. None of the above.
Submitted by c-admin on Tue, 05/28/2019 - 04:17
What will be the result of attempting to compile and run the following code?
public class PromotionTest{
public static void main(String args[]){
int i = 5;
float f = 5.5f;
double d = 3.8;
char c = 'a';
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2;
System.out.println(c);
}
}
Select 1 option
A. The code will fail to compile.
B. It will print d.
C. It will print c.
D. It will print b
E. It will print a.
Submitted by c-admin on Tue, 05/28/2019 - 04:11
Which of the following are valid operators in Java?
Select 4 options
A. !
B. ~
C. &
D. %=
E. $
Submitted by c-admin on Tue, 05/28/2019 - 04:05
What will the following code print when run without any arguments ...
public class TestClass {
public static int m1(int i){
return ++i;
}
public static void main(String[] args) {
int k = m1(args.length);
k += 3 + ++k;
System.out.println(k);
}
}
Select 1 option
A. It will throw ArrayIndexOutofBoundsException.
B. It will throw NullPointerException.
C. 6
D. 5
E. 7
F. 2
G. None of these.
Pages