Java MCQ : Data Types in Java (Multiple Choice Questions)
Question 1 |
Guess the output of the following program -
public class NumberSystem{ public static void main(String[] args){ int hexVal = 0x1a; System.out.println("Value : " + hexVal); } }
26 | |
24 | |
32 | |
25 |
Question 1 Explanation:
0x1a = 0001 1010 = 2^1 + 2^3 + 2^4 = 2 + 8 + 16 = 26
Question 2 |
Guess the output of the following program -
public class NumberSystem{ public static void main(String[] args){ int val = 0b11010; System.out.println("Value : " + val); } }
64 | |
26 | |
28 | |
32 |
Question 2 Explanation:
Its binary representation of 26. Binary Literal is accepted in latest JDK 7.
Question 3 |
Which of the following Class is used to wrap boolean value.
java.io.Boolean | |
java.util.Boolean | |
java.lang.Boolean | |
None of these |
Question 4 |
We can construct Boolean Object from ________. Select appropriate option(s).
boolean | |
String | |
Integer | |
Long |
Question 5 |
public Boolean (boolean value)is used to construct the __________ .
None of these | |
Floating Object | |
Boolean Object | |
Integer Object |
There are 5 questions to complete.