AP Computer Science Amediummcq1 pt

If class B extends A, the statement B x = new A() is

A.a compile error without a cast
B.legal
C.a runtime error always
D.legal with any object

Explanation

Core Concept

A superclass object is not a subclass.

Correct Answer

Aa compile error without a cast

More Unit 9: Inheritance practice questions

Try a random question →

Practice more AP Computer Science A questions with full explanations

Practice Unit 9: Inheritance Questions →