Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct?

Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct?


A. A a = new A();
B. A a = new B();
C. B b = new A();
D. B b = new B();

The correct answer is B.

Explanation: Since B is a concrete class with a default constructor, d is correct. Since an instance of B is also an instance of A, b is also correct.


Java

Learn More Multiple Choice Question :