Java OCA OCP Practice Question 2727

Question

Given:

1. public class Rectangle implements Shape { Office[] j; }  
2. abstract class Printer { String s; Printer b; }  
3. interface Printable { }  
4. interface Shape extends Printable { int x = 7; }  
5. class Office { Printer b; } 

Which are true? (Choose all that apply.)

A.   Rectangles have a Printer.
B.   Offices implement Printables.
C.   Rectangles implement Printers.
D.   Offices have a String.
E.   Printers implement Shapes.
F.   Printers have a Printer.


A, D, and F

Note

A, D, and F correctly describe some of the relationships within the code.

Rectangles have Printers indirectly through Offices.

Offices have Strings indirectly through Printers, and Printers have Printers because it's very common to want to make linked lists with your Printers.

B and E are incorrect because no such hierarchies exist in the code.

C is incorrect because Rectangles "have" Printers (indirectly), but they don't implement them.




PreviousNext

Related