In many places, it is mentioned that java is a single inheritance programming language. But we can implements many interfaces to a class and then inheritances from more interfaces.so my problem is whether Java is Single inheritance or multiple inheritance.and please explain why.
fred rosenberger wrote:You can IMPLEMENT many interfaces. But you can only EXTEND one class.
I am not the expert here by any means, but to me, inheritance means "extends". You get stuff for free when you say "public class MyClass extends SomeOtherClass". You get methods.
When you say "public class MyClasss implements SomeInterface, SomeOtherInterface", you don't. You have to then go and implement the methods.
That's how I see the difference.
I don't see it that way.
There's really no fundamental difference between "implements" and "extends". They both specify inheritance, and IS-A relationship. It just so happens that the language designers decided to make a distinction in the keywords used. There's no real difference between extending a purely abstract class and implementing an interface.
Jeff Verdegan wrote: There's no real difference between extending a purely abstract class and implementing an interface.
But there is a difference between extending a concrete class and extending an interface. whipping these up (so they may not be 100% correct):
Maybe it is a distinction without a difference. And again, I'm not an expert here. But this is how I see the difference.
But that extends/implements difference is exactly the same as the difference between extending a concrete class and extending a class with only abstract methods. It's not really a difference between extends and implements, but rather between whether you're inheriting from a concrete type or an abstract type.