Difference between a Java interface and a Java abstract class?
April 23rd, 2008- Methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
- Variables declared in a Java interface is by default final. A Java abstract class may contain non-final variables.
- Memebers of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
- Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
- An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
- A Java class can implement multiple interfaces but it can extend only one abstract class.
- Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
- In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.



5. An interface can extend another Java interface only [...]
It sounds like what you’re saying is that an interface can
ONLY extend ONE other interface?
No, an interface can extend multiple interfaces.
Probably I should have phrased point 5 as, “an interface can extend other interfaces and cannot extend an abstract or concrete class. Also, an interface cannot implement (but extend) other interfaces”.
Thank mjt for pointing out.
please sed this complete ooks for me
if interface object’s initialization with corresponding class instanciation examples would have presented.
Instead of picking points from Java books about the differences, it would be better if you describe the main advantages of using interfaces and abstract class, when to use interface and abstract classes. That would add value to your question and make easy understand to the viewer.
What Unknown is saying correct.
One more point – If I dont want multiple inheritence then which one is better to use?? Interface or abstract class??
The point no 8.
“In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.”
What is this “extra indirection”. I have seen same thing in other sites without clear information.
Also How can we prove that java interfaces are slow than abstract classes.
simple….read SCJP kathy sierra’s book….best as far as i know…
good i lern very much from this sight
thanks for giving expalnation and i need more details about core java