🎴 Flashcard Mode

Model 204 and Java Programming Quiz

Card1 / 20
Mastered0
Review0
QuestionClick to flip

Class Y is a subclass of Class X.Will this compile? Y myY=new Y(); X myX=myY;

AnswerClick to flip back
A
Yes
💡 Explanation:

Since Class Y is a subclass of Class X, an instance of Y can be implicitly upcast to a reference of type X. This is a fundamental polymorphic assignment in Java and compiles successfully.

Change Mode