0
What's the difference between "Abstract class" and "Interface"?
I found that interface is more familiar in others' code, is that means I need not to use abstract class on usual?
2 Answers
+ 8
Differences between abstract class and interface:
1 Abstract class can extend only one class or one abstract class at a time
1 Interface can extend any number of interfaces at a time
2 Abstract class can extend from a class or from an abstract class
2 Interface can extend only from an interface
3 Abstract class can have both abstract and concrete methods
2 Interface can have only abstract methods
4 A subclass can extend only one abstract class
4 The same subclass can implement as many interfaces as you like
5 Interface can have only public abstract methods and it is not mandatory to declare them abstracts because they are abstracts by deafault.
6 Abstract class can have static, final or static final variable.
6 Interface can have only static final (constant) variable i.e. by default.
So it depends what you need the abstract class/Interface for. Both are usefull.
0
Thanks man