Which two statements, if either were true, would make the code compile?

Given the following segment of code:

Which two statements, if either were true, would make the code compile? (Choose two.)
A. MotorCycle is an interface that implements the Cycle class.
B. Cycle is an interface that is implemented by the MotorCycle class.
C. Cycle is an abstract superclass of MotorCycle.
D. Cycle and MotorCycle both extend the Transportation superclass.
E. Cycle and MotorCycle both implement the Transportation interface.
F. MotorCycle is a superclass of Cycle.

Download Printable PDF. VALID exam to help you PASS.

7 thoughts on “Which two statements, if either were true, would make the code compile?

  1. Since we have a list of “Cycle”, anything at it’s hierarchical level or below it qualifies as addable to the list. So anything that implements it as an interface, or extends it through inheritance.
    BUT NOT ANYTHING ABOVE IT! Adding “new Object()” to the list would call in the compiler to reject you in life as did your father.

  2. B, C. Both statements confirms that MotorCycle is inheriting from the Cycle (whether is it an interface or an abstract class). The important point to remember here is that the myList is an ArrayList that includes objects of type Cycle (ArrayList). Accordingly, we can add any object of type Cycle or any subclass that inherits from it.

Leave a Reply

Your email address will not be published. Required fields are marked *