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);
    }
}
A
26
B
24
C
32
D
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);
    }
}
A
64
B
26
C
28
D
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.
A
java.io.Boolean
B
java.util.Boolean
C
java.lang.Boolean
D
None of these
Question 4
We can construct Boolean Object from ________. Select appropriate option(s).
A
boolean
B
String
C
Integer
D
Long
Question 5
public Boolean (boolean value)
is used to construct the __________ .
A
None of these
B
Floating Object
C
Boolean Object
D
Integer Object
There are 5 questions to complete.