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.
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.
If you want to solve the questions together with the experts and understand the concepts better, please contact us using the contact form or WhatsApp numbers. Selected people get to do that without any additional charges.