The main reason is abstract class may have abstract methods . An abstract method is like template/contract, according to inheritance rule every concrete subclass must have to provide a concrete definition of the same. So we can say the abstract method is the only declaration.
Now for a moment we assume we can create an instance of abstract class
so, we have an abstract class name Shape and an abstract method getShape()
Abstract class looks like,
public abstract Shape
{
public abstract getshape(); //Only declaration
}
Now, next step is to create an Object of abstract shape as we assume we can instantiate the abstract class.
Shape s =new shape();
and call
s.getshape();
Think what it will return as it is the only declaration!!!! so JVM functionality will break.
Due to that, we can't instantiate the abstract class.
Now for a moment we assume we can create an instance of abstract class
so, we have an abstract class name Shape and an abstract method getShape()
Abstract class looks like,
public abstract Shape
{
public abstract getshape(); //Only declaration
}
Now, next step is to create an Object of abstract shape as we assume we can instantiate the abstract class.
Shape s =new shape();
and call
s.getshape();
Think what it will return as it is the only declaration!!!! so JVM functionality will break.
Due to that, we can't instantiate the abstract class.
Post a Comment