Multiple choice

Option B is correct. It would be correct if the code had compiled, and the subclass Alphahad been saved in its own file. In this case Java supplies an implicit call from the sub-class constructor to the no-args constructor of the super-class therefore line 12 causesBase to be output. Line 13 also causes Base to be output. Option A is wrong. It would be correct if either the main class or the subclass had not been instantiated. Option C is wrong. The code compiles. Option D is wrong. There is output.

  1. 0 2 4

  2. 0 2 4 6

  3. Compilation fails at line 2

  4. Compilation fails at line 10

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

Nonnested classes cannot be marked protected (or final for that matter), so the compiler will fail at protected class NewTreeSet.