Why abstract methods in Java cannot be static?

My answer to Why abstract methods in Java cannot be static?

Answer by Vaibhav Kashyap:

Abstract methods are meant to be overridden in order to use them because when you declare a method as abstract it just has its structure, that particular method doesn't have the body of the method. Therefore in order use, we need to override and implement their body. And by the virtue of the fact class containing an abstract method has to be abstract therefore a class extending an abstract class (containing abstract method) if it doesn't implement an abstract method of parent abstract class then the class extending the abstract class has be declared abstract too. Now lets introduce 'static' here. Java says static inhibits overriding because overriding depends on having an instance of a class. The point of polymorphism is that you can subclass a class and the objects implementing those subclasses will have different behaviours for the same methods defined in the superclass (and overridden in the subclasses). A static method is not associated with any instance of a class so the concept is not applicable. In layman terms, static makes a class level reference instead of object level reference. An abstract class cannot be instantiated. In order to use the method of abstract class you need to have reference to it generated with the help of the class extending it which is an indirect object reference.

Cheers!!!

Why abstract methods in Java cannot be static?

Advertisements

Currently Working as Game Developer at Gaussian Networks Private Limited , ( www.adda52.com ). Did B.Tech in computer science Engineering from G.G.S.I.P University , new delhi. Using Java , ActionScript 3.0 and PHP for development. I am a programmer who loves to adapt new platforms for coding. Reading techs & specs of gadgets is my hobby as i am a 24x7 active web crawler. I consider learning as a best helping aid to yourself as well as for others because it's the best means for diversifying your knowledge.

Posted in J2SE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: