Sunday, July 22, 2007

When do we go for Abstract classes and when do we go for Interfaces in java

Abstract class is a class that contains 0 or more abstract methods and also ordinary methods. Interface is specification of method prototypes(all abstract methods only).

Whenever the developers wants to use some features be shared by all objects(different classes), that time they go for abstract class.

When the developers wants different implementation for every objects then they go for interface.

We cannot create the object for abstract and interface. Instead we can create the reference of abstract class and interface.

No comments: