Hi,
I know its one of the very common question in every java programmers mind. We all know the diff between interface and abstract class.
Can any one explain me when i have to choose interface / abstract class when i am doing my design??
Printable View
Hi,
I know its one of the very common question in every java programmers mind. We all know the diff between interface and abstract class.
Can any one explain me when i have to choose interface / abstract class when i am doing my design??
When you only have methods that you know need to be implemented, use an interface. ActionListeners all must implement the actionPerformed() function, but each implementation is going to be different, so it's an interface.
When you have a partial class that you need to "fill in" with implementations of certain methods, or if you do not want a class to be instantiable, use an abstract class. An AbstractList is an example of this.