An abstract class is just that, it is abstract, it is not a 'real' thing. It is used as the basis for real classes so it may contain some implemented methods that will be common among all derived classes. But it will also contain some methods without implementation, as place holders for the derived ones. See http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html[^] for more details.
Though the concept of a constructor in an abstract class may look strange due to the fact that you cannot create an instance, it has still some meaning. The abstract class' constructor can do e.g. some initialization work and can be called from any derived class - i.e. when you create an instance of a derived class you indirectly call the constructor of the abstract base class too.
An Abstract class is a class that is declared as abstract. It may or may not include abstract methods.
We must declare Abstract class and Abstract methods with the key word abstract.
Abstract classes cannot be instantiated, means we can't create an object to Abstract class. We can create through Subclasses to Abstract classes.
Abstract methods in the sense without body..i.e there is no implementation right..
So in that case JVM does not know how much memory it has to allocate for that abstract method because abstract method does not have body implementation.
So JVM will not able to allocate memory for the abstract methods when the time of creating instance to Abstract class.
So JVM unable to create the instance to Abstract class. So that we can't create the object for the Abstract class.
If we use little sense, Abstract method is a non-static(not allows static) method, if we are allowed to create object for abstract method we can invoke that abstract method, which can not be executed. What is the use of it to invoking the unimplementation method.
Hence to restrict calling abstract method compiler will not allow instantiation abstract class.
Ok, Good , you may raise a question…In Abstract class not only Abstract methods we can create Concrete methods also which is having the implementation, so why, In that case also we can't create the instance for the Abstract class. Why because the abstract keyword simply indicates to JVM that the class cannot be instantiated.
Hence the designers of Java made the JVM that when it find abstract keyword for any class then JVM can't create the instance for that class.
Abstraction is just an Idea, there is no physically exists.
Above I written a statement Abstract method is a non-stattic method. Why Abstract method has not allows static modifier?
If we declare Abstract method as static , it is identified at the time of class loading and further can be invoked which can not be instantiated.
So ,Abstract method can not declare as static. If we declare it gives the compile time error: Illegal combination of modifier: abstract and static.
You know the Java class loader is also an abstract class...
Ok boss, I heard abstract class has constructor...Is it Right...
yes, absolutely, then why constructor ?
simple answer is for initializing the sub class...
There is a good reason behind this ,I will explore this in detail in my next post .
Hope its may help you...
give u r valuable comment to correct my knowledge, in case i'm wrong in this section...
if you have any doubts also write your doubt as a comment.