Hi,
This is a question from Dan's mock exam.
class SRC117 {
public static void main (
String[] args) {
double d1 = Math.random();
boolean b1 = (d1 < 0.0), b2 = (d1 <= 0.0), b3 = (d1 == 0.0);
boolean b4 = (d1 >= 0.0), b5 = (d1 < 1.0), b6 = (d1 <= 1.0);
boolean b7 = (d1 == 1.0), b8 = (d1 >= 1.0), b9 = (d1 > 1.0);
}}
Which of the boolean variables will never be initialized to the value true?
a. b1
b. b2
c. b3
d. b4
e. b5
f. b6
g. b7
h. b8
i. b9
I selected the options b1,b6,b7,b8,b9 but the ans is b1,b7,b8,b9(b6 is not included) but why?. I know i am missing something out here but am so exhausted ,not able to figure it out.Pl. clarify.
-Sanjana