Test Series - java

Test Number 11/64

Q: What are the two floating point notations in Java language?
A. Exponential e or E (10^a)
B. Exponential p or P (2^a)
C. A and B
D. None of the above
Solution: no solution
Q: Choose the correct implementation of floating point literals in the exponential form in Java.
A. float a = 12.0e2f; //1200.0
B. float a = 100.0e-2f; // 1.0
C. float a = 123.456e-21f; //1.23456E-19
D. All the above
Solution: no solution
Q: Choose the correct usage of boolean literal in the options below.
A. boolean b= false;
B. boolean b= 2<4; //2<4 is true;
C. if(true) { System.out.println("HELLO"); }
D. All the above
Solution: no solution
Q: What is the output of this Java snippet?
int a = 0b111;
System.out.println(a);
A. 111
B. 7
C. 8
D. Compiler error
Solution: 1x2^2 + 1x2^1 + 1x2^0
1x4 + 1x2 + 1
4 + 2 + 1
Q:  Choose the wrong Java code statement below.
A. boolean a = false;
B. boolean a = (5>6)||(4>3);
C. boolean a = 1;
D. boolean a = 4>3?true:false;
Solution: You can not assign an integer value to a boolean data type. Java does not convert integers to boolean true or false.
Q: What is the default boolean literal assigned to a boolean variable in Java?
A. true
B. false
C. undefined
D. None of the above
Solution: Default values are assigned only to the instance variables.

You Have Score    /6