File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static with abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static with abstract" Watch "static with abstract" New topic

static with abstract

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
abstract modifier can't be used with static modifier.
Can someone please tell me the reason for this.
I guess if i know the reason it'll be easier to remember.
Swamy Nathan
Ranch Hand

Joined: May 16, 2004
Posts: 187
abract means a concrete implementation may override it. It also means that if the abstract class is used as a base class and the method when invoked will cause the actual instance's method to be invoked (polymorphism). This of course implies that the method should be an instance method. Hence it cannot be static.
Sundar Murthi
Ranch Hand

Joined: Mar 05, 2004
Posts: 209

I hope Concrete implamentations must define the abstract methods.

my assumption is
Actualy abstract means not fully defined. You can say, a method is Not fully defined then how it is resanable to say it is common to all instances of a class.

i think
the concreate class can able to defined as static

but i am not sure.
Sanyev Babu
Ranch Hand

Joined: Dec 18, 2003
Posts: 132
An abstract method means that the method is not implemented. A static method means that the method can be accessed using the class name. It is not tied to any instance of the class. So if we declare a method as abstract then it should not be accessed. If you make that method static it becomes accessible which is not acceptable. (Why should we access a method which is not implemented) So it should result in a compile time error.

Regarding classes a top level class cannot be made static. So there is no question on abstract and static coming together.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I remember it this way:

1. a static method cannot be overridden.
2. an abstract method must be overridden to give it an implementation.

You can't have both of these, so both static and abstract are not allowed.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: static with abstract
It's not a secret anymore!