Oracle
1Z0-851 · Question #195
Given: class Thingy { Meter m = new Meter(); } class Component { void go() { System.out.print("c"); } } class Meter extends Component { void go() { System.out.print("m"); } } class DeluxeThingy…
The correct answer is F. DeluxeThingy is-a Component. See the full explanation below for the reasoning.
Question
Given: class Thingy { Meter m = new Meter(); } class Component { void go() { System.out.print("c"); } } class Meter extends Component { void go() { System.out.print("m"); } } class DeluxeThingy extends Thingy { public static void main(String[] args) { DeluxeThingy dt = new DeluxeThingy(); dt.m.go(); Thingy t = new DeluxeThingy(); t.m.go(); } } Which two are true? (Choose two.) A.
Options
- BThe output is mm.
- CThe output is mc.
- DComponent is-a Meter.
- EComponent has-a Meter.
- FDeluxeThingy is-a Component.
- GDeluxeThingy has-a Component.
How the community answered
(31 responses)- B3% (1)
- D3% (1)
- E6% (2)
- F74% (23)
- G13% (4)
Community Discussion
No community discussion yet for this question.