nerdexam
Oracle

1Z0-819 · Question #107

Given: enum QUALITY { A(100), B(75), C(50); int percent; private QUALITY(int percent) { this.percent = percent; } } and checkQuality(QUALITY A); and void checkQuality(QUALITY q) { switch (q) { case…

The correct answer is B. A. See the full explanation below for the reasoning.

Question

Given: enum QUALITY { A(100), B(75), C(50); int percent; private QUALITY(int percent) { this.percent = percent; } } and checkQuality(QUALITY A); and void checkQuality(QUALITY q) { switch (q) { case ?: Insert code here */ : System.out.println("Best"); break; default: System.out.println("Not Best"); break; } } Which code fragment can be inserted into the switch statement to print Best?

Options

  • AQUALITY.valueOf()
  • BA
  • CtoString()
  • DQUALITY.A

How the community answered

(35 responses)
  • A
    6% (2)
  • B
    80% (28)
  • C
    11% (4)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice