Oracle
1Z0-851 · Question #32
Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? (Choose two.)
The correct answer is A. class Widget { Sprocket s; } class Gadget extends Widget { Spring s; } C. class Widget { Sprocket s1; Spring s2; } class Gadget extends Widget { }. See the full explanation below for the reasoning.
Question
Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? (Choose two.)
Options
- Aclass Widget { Sprocket s; } class Gadget extends Widget { Spring s; }
- Bclass Widget { } class Gadget extends Widget { Spring s1; Sprocket s2; }
- Cclass Widget { Sprocket s1; Spring s2; } class Gadget extends Widget { }
- Dclass Gadget { Spring s; } class Widget extends Gadget{ Sprocket s; }
- Eclass Gadget { } class Widget extends Gadget{ Sprocket s1; Spring s2; }
- Fclass Gadget { Spring s1; Sprocket s2; } class Widget extends Gadget{ }
How the community answered
(69 responses)- A75% (52)
- B4% (3)
- D13% (9)
- E6% (4)
- F1% (1)
Community Discussion
No community discussion yet for this question.