nerdexam
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)
  • B
    3% (1)
  • D
    3% (1)
  • E
    6% (2)
  • F
    74% (23)
  • G
    13% (4)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice