221k views
5 votes
What happens if we try to instantiate an abstract base class

A) Compilation error
B) Runtime error
C) No error, but the program may crash
D) Instantiation succeeds

User DPD
by
8.0k points

1 Answer

4 votes

Final answer:

Trying to instantiate an abstract base class leads to a compilation error because abstract classes are designed to serve as a base for subclasses to implement the detailed behavior(option a).

Step-by-step explanation:

If we try to instantiate an abstract base class, the result will typically be a a) compilation error.

An abstract class is intended to provide a base for other classes to extend and is not meant to be instantiated on its own. In object-oriented programming, abstract classes can contain abstract methods which have no implementation and therefore, instantiating such a class doesn't make sense because it may contain incomplete methods that were meant to be implemented by a subclass. Trying to instantiate an abstract class is often caught at compile time, not run time, highlighting the error in the code.

User Christopher Kikoti
by
7.9k points