nerdexam
Oracle

1Z0-819 · Question #3

Given: public class Tester { public static void main(String[] args) { char letter = 'b'; int i = 0; switch (letter) { case 'a': i++; break; case 'b': i++; case 'c': // 'd': // line 1 i++; case 'e'…

The correct answer is F. The compilation fails due to an error in line 1. See the full explanation below for the reasoning.

Question

Given: public class Tester { public static void main(String[] args) { char letter = 'b'; int i = 0; switch (letter) { case 'a': i++; break; case 'b': i++; case 'c': // 'd': // line 1 i++; case 'e': i++; case 'f': i++; break; default: System.out.print(letter); } System.out.println(i); } } What is the result?

Options

  • Ab1
  • Bb2
  • Cb3
  • D1
  • Eb3
  • FThe compilation fails due to an error in line 1.

How the community answered

(66 responses)
  • A
    6% (4)
  • B
    2% (1)
  • C
    14% (9)
  • D
    2% (1)
  • E
    3% (2)
  • F
    74% (49)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice