An abstract class is a class which doesnt have an implementation for one or more methods. It means that the jvm doesnt have any direction of what to do in case if someone calls the method which is abstract. So if you are able to create an object for the abstract class and call any abstract method of it the jvm will not be able to decide what to do and hence it my be crashed. So to avoid this situation we are restricted to instantiate a abstract class. If you need a object for that abstract class create a concrete subclass and create an object for it and use it.
An abstract class can include concrete methods and fields. In fact, an abstract class does not need to include any abstract methods. The abstract modifier simply indicates that the class cannot be instantiated.
Amit Patil
Sep 19th, 2007
We cant create an object for object class as it is supposed to be used in inheritance heirarcy. Abstract class may contain abstract methods which the inheriting class should implement. The abstract class may not contain abstract methods but is defined abstract just to prevent instantiation
To create objects we generally use new keyword mentioning indirectly the size to allocate the memory. We do not know the size occupied by abstact methods so we cannot create object for abstract methods.
Abstract Class is an incomplete class, a class which acts as Prototype Model for actual classes.
Also, Abstract Class have one or more pure virtual functions, i.e. having No Body, no implementation and with NULL Function pointers.
Thus, while being instantiation of an object of such class, compiler is not able to set the reference for all of the member functions, hence...
Creation of an object of such class (Abstract Class) gives compiler error, and do not allow one to create it.
vijaya
Jul 16th, 2015
In Most of the situations abstract classes contains only abstract method, some times abstract classes contains non-abstract methods also but its not recommended to write non-abstract methods in abstract classes. The purpose of creating object for a class is, for calling the methods of that class (for doing some task) abstract methods not having any implementation means these methods cant able to do anything, so we cant perform any thing by calling that method strictly speaking its unnecessary to call abstract methods, that is why they restrict the object creation of abstract classes
ambarish upadhyay
Aug 7th, 2015
We cannot create object in abstract class because when we can compile the abstract class the compiler create them incomplete so in the abstract class we cannot create object
Naveen Kumar K R
Jan 17th, 2016
In this case JVM does not know how much memory it has to allocate for that abstract method, because abstract method does not have any implementation. So JVM will not be able to allocate memory for that abstract method
Rowan Siwakoti (NepWeb)
Jun 10th, 2016
We can create object of an abstract class indirectly by using anonymous inner class. Thank you :)
akansha
Feb 28th, 2018
As you say abstract class has no complete body that is why we cannot create object but if we completed this body after that we also cannot create object why?
Why can't we create object for an abstract class?