Abstract Static Method looks odd as it cannot exist in Java and declaring so, compiler will not keep quiet. Discussed with Example, Screenshot in Simple terms in Question/Answer format for a Beginner.
1. Can we declare Abstract Static Method?
Before answering this question, let us brief about abstract methods.
Following points are to be remembered with abstract methods.
2. An abstract class can have the following combinations of methods.
- All methods abstract
- All methods concrete (non-abstract)
- A mixture of abstract and non-abstract methods
Observe, it the above list Abstract Static Method does not exist.
Now we have a different question to be answered.
2. Can an abstract class have static methods?
Yes, definitely can have as a static method is special flavor of concrete method. We know a static method can be called with object name (not possible here), class name and directly without the help of an object. Following program explains.
abstract class Test
public static void display()
public class Demo extends Test
public static void main(String args)
Now another confusing question is to be answered.
3. Can an interface have static methods?
No, impossible. A person having a little knowledge of interfaces can answer.
All methods of an interface must be public and abstract (by default takes also if not mentioned). As static methods should have a body, the interface methods cannot be static.
More on abstract classes and interfaces.
1. Extends Implements
2. Getting objects of Interfaces – Through Object Casing
3. Java Constructor Properties
4. Abstract class constructor & Interface abstract
5. Why the methods of an interface should be overridden as public only?