Monday, December 3, 2012

Similarities and Differences [Interface and Abstract Class]

Interface and Abstract Class

Similarities:
The only similarity between Interface and Abstract class is that both can not be instantiated.

Differences:
  1. An abstract class can have methods with implementation, to provide some default behavior.An interface can not have any implementation.
  2. All the variables in the interface are final by default. An abstract class can have non-final methods.
  3. All the methods in an interface are public by default. An abstract class can have protected and ...
  4. If we want to implement an interface we would use implements. For an abstract class we would use extends.
Whats the need of interface when we have Abstract class?

No comments:

Post a Comment