This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Java does not allow multiple inheritance for classes, but for interface it's possible to inherit from multiple interfaces ?. What the reason for this ?. Why does java allow multiple inheritance in interface and not for classes ?
Java does not allow multiple inheritance for classes, but for interface it's possible to inherit from multiple interfaces ?. What the reason for this ?. Why does java allow multiple inheritance in interface and not for classes ? The main motivation for interfaces in java's beginning was to get away from multiple inheritance. If you really think about one interface extending another, it is not so much inheritance as it is concatenation. Class inheritance is a lot more than merely summing all the methods and instance variables. Classes must be instantiated thru the whole hierarchy from most specific instance to most general (always an instance of Object for java). Interfaces cannot be instantiated. Further consider the almost intolerable restriction that limiting interface implementation to a single interface. Class design would be greatly diminished. Having a class implement more than one interface is semantically equivalent to one interface extending the remaining interfaces. The reason java does not allow multiple class inheritance is because it creates more problems than it solves for compiler, runtime and programmer. Take a look at this thread for a discussion on that subject.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher