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.
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
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