This a quick reminder about pros and con's of Java abstract classes and interfaces:
Interface
- A class can implement multiple interfaces
- An interface cannot provide any code at all
- An interface can only define public static final constants
- An interface cannot define instance variables
- Adding a new method has ripple effects on implementing classes (design maintenance)
- JAXB cannot deal with interfaces
- An interface cannot extends or implement an abstract class
- All interface methods are public
Abstract Class
- A class can extend at most one abstract class
- An abstract class can contain code
- An abstract class can define both static and instance constants (final)
- An abstract class can define instance variables
- Modification of existing abstract class code has ripple effects on extending classes (implementation maintenance)
- Adding a new method to an abstract class has no ripple effect on extending classes
- An abstract class can implement an interface
- Abstract classes can implement private and protected methods
0 comments :
Post a Comment