Oracle
1Z0-851 · Question #9
Given: class Atom { Atom() { System.out.print("atom "); } } class Rock extends Atom { Rock(String type) { System.out.print(type); } } public class Mountain extends Rock { Mountain() { super("granite…
The correct answer is F. atom granite atom granite. See the full explanation below for the reasoning.
Question
Given: class Atom { Atom() { System.out.print("atom "); } } class Rock extends Atom { Rock(String type) { System.out.print(type); } } public class Mountain extends Rock { Mountain() { super("granite "); new Rock("granite "); } public static void main(String[] a) { new Mountain(); } } What is the result?
Options
- ACompilation fails.
- Batom granite
- Cgranite granite
- Datom granite granite
- EAn exception is thrown at runtime.
- Fatom granite atom granite
How the community answered
(16 responses)- A6% (1)
- D13% (2)
- E6% (1)
- F75% (12)
Community Discussion
No community discussion yet for this question.