Multiple choice technology programming languages

What will be the result of executing the following code? 1. boolean a = true; 2. boolean b = false; 3. boolean c = true; 4. if (a == true) 5. if (b == true) 6. if (c == true) System.out.println("Some things are true in this world"); 7. else System.out.println("Nothing is true in this world!"); 8. else if (a && (b = c)) System.out.println("It's too confusing to tell"); 9. else System.out.println("Hey this won't compile");

  1. The code won't compile

  2. Some things are true in this world

  3. Hey this won't compile

  4. none of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The code is a nested if-else structure. 'if (a == true)' is true. Then it checks 'if (b == true)', which is false. This triggers the 'else if (a && (b = c))' on line 8. Since 'a' is true and the assignment '(b = c)' evaluates to true, it prints 'It's too confusing to tell'. Since this is not an option, 'none of the above' is correct.