Which declaration initializes a boolean variable?
A.
boolean h = 1;
B.
boolean k = 0;
C.
boolean m = null;
D.
boolean j = (1 < 5) ;
Explanation:
The primitive type boolean has only two possible values: true and false. Here j is set to (1 <5), which evaluates to true.
“D”
Boolean primitive type is only set to True/False, here (1<5) only returns True.
The Answer is D.
A Java boolean variable can only be true or false, nothing else. Uninitialized boolean instance variables of a class default to false.
D