ExamVeda
Login
Home
Interfaces and Abstract Classes
?

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?
1. A a = new A();
2. A a = new B();
3. B b = new A();
4. B b = new B();

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Akash Mulik
Akash Mulik 9 years ago
Option 1. & 3. is wrong because we cant create object of abstract class.
2 & 4 are correct because B is concrete class and its object is created and in Option 2, reference of class A(abstract class) can be used to hold its child class's object.