nerdexam
Oracle

1Z0-851 · Question #46

Given: public class Test { public static void main(String [] args) { int x = 5; boolean b1 = true; boolean b2 = false; if ((x == 4) && !b2 ) System.out.print("1 "); System.out.print("2 "); if ((b2 =…

The correct answer is D. 2 3. See the full explanation below for the reasoning.

Question

Given: public class Test { public static void main(String [] args) { int x = 5; boolean b1 = true; boolean b2 = false; if ((x == 4) && !b2 ) System.out.print("1 "); System.out.print("2 "); if ((b2 = true) && b1 ) System.out.print("3 "); } } What is the result?

Options

  • A2
  • B3
  • C1 2
  • D2 3
  • E1 2 3
  • FCompilation fails.
  • GAn exception is thrown at runtime.

How the community answered

(41 responses)
  • A
    5% (2)
  • C
    2% (1)
  • D
    76% (31)
  • F
    5% (2)
  • G
    12% (5)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice