60.3k views
1 vote
Given code:public abstract class A{ }public class B extends A{}The following code sequence would correctly create an object reference of class A holding an object reference for an object of class B:A c;c = new B();TrueFalse

1 Answer

1 vote

Answer:

True.

Step-by-step explanation:

In the code given in the question we have an abstract class A.Then we have a class B which inherits the class A it is also an example of single inheritance.

Line A c; creates a reference of A type.

Line c=new B(); states that the reference of A type will refer to an object of class B.

Hence we conclude that the answer is True.

User Ruben
by
7.5k points

No related questions found