B. Cycle is an interface that is implemented by the MotorCycle class.
E. Cycle and MotorCycle both implement the Transportation interface.
Explanation:
B. Cycle is an interface that is implemented by the MotorCycle class.
If Cycle is an interface and MotorCycle is a class that implements that interface, the code can compile successfully.
E. Cycle and MotorCycle both implement the Transportation interface.
If both Cycle and MotorCycle classes implement the Transportation interface, the code can compile successfully.
The other options are not valid based on the typical Java class hierarchy and interface implementation rules:
A. MotorCycle is an interface that implements the Cycle class.
This is not a valid Java syntax. An interface cannot implement a class.
C. Cycle is an abstract superclass of MotorCycle.
This is not the usual relationship between an interface and a class in Java. Interfaces are implemented, and classes are extended.
D. Cycle and MotorCycle both extend the Transportation superclass.
This is not mentioned in the code or the question, and there's no indication of a "Transportation" superclass.
F. MotorCycle is a superclass of Cycle.
This is not the typical relationship between an interface and a class in Java. Interfaces are not superclass/subclass relationships.
The correct answer is CD, I'll give you a tip to get questions about inheritance right. Always think that a Father can be a son but a son cannot be a father. With that in mind let's solve the questions:
A -> Wrong, Motocycle cannot implement Cycle, otherwise the code would be wrong because we call Motocycle type object inside cycle.
B -> That's correct, Cycle can be an interface and a variable can be an interface and since MotorCycle implements Cycle it is a child of Cycle.
C -> You are correct, Cycle can be a superclass of Motorcycle.
D and E -> If they are extending or implementing the same class, they are not parent and child of each other then they are wrong.
F -> Remember the tip I gave? Well, a son cannot be a father.
A cannot be true as we cannot instantiate an interface (MotorCycle)
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
MPignaProTech
2 months, 3 weeks agoSisar
4 months, 2 weeks agoduydn
1 year, 4 months agodsms
1 year, 5 months agodsms
1 year, 5 months agoUAK94
2 years, 3 months agoiSnover
2 years, 3 months agoiSnover
2 years, 3 months agoalex_au
2 years, 3 months ago