| Author |
Interface vs Abstract class
|
prat de
Greenhorn
Joined: Sep 15, 2003
Posts: 22
|
|
why to use Interface in java if we can accomplish the same thing by using Abstract Class...in terms of defering implementation of methods.. please let me know if any of my friends here can answer this question - prat.
|
 |
Andres Gonzalez
Ranch Hand
Joined: Nov 27, 2001
Posts: 1561
|
|
hmm.. good question.. probably because an interface is 100% abstract class (you cannot have any method with a body), whereas in an abstract class you can even have no abstract methods at all (although IMO it wouldn't make sense to declare it as abstract). I think the interface gives more flexibility than an abstract class. any other opinions?
|
I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
|
 |
Gayathri Prasad
Ranch Hand
Joined: Jun 25, 2003
Posts: 116
|
|
Hi, The support for multile inheritance is achieved through interfaces. Thus interfaces are required and thus both are porvided. Cheers, Gaya3 ------------------------------------------ Prasanna Kumar R.V
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
See Why Extends Is Evil. Allen Holub cautions us to think twice before extending a class, and illustrates how interfaces leave much more flexibility for the future. I've used abstract classes in frameworks, where some functionality is provided and the extending class can override "developer hook" methods to plug in additional functionality. Holub fairly well rips up the MFC for doing this, so maybe I shouldn't admit it so freely.  [ September 16, 2003: Message edited by: Stan James ]
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: Interface vs Abstract class
|
|
|