If we implementing an interface then is that should be inheritance? Kindly any one clarify my doubt
no, it is not inheritance. there are two things you can check:
1. multiple inheritance is not supported by Java, and you can implement multiple interfaces for each class
2. there is nothing in an interface you can actually inherit
stultuske was right until last month.
The latest version of Java (Java 8) allows static methods and "default" instance methods to be defined in interfaces, which are inherited by any class that implements the interface.
should 've mentioned that, indeed. but most exams and companies still use Java 7 (or below), so if they ask you that, do mention that it's only since Java 8 that you can inherit (you don't automatically do) from interfaces.
What exactly did you mean by "(you don't automatically do)"? If the interface defines a default method then you inherit it, whether you meant to or not.
Hi JamesCherrill and Stultuske,
Thanks for the healthy discussion
I meant that by creating an interface, that doesn't mean there is a default method in there.
implementing Serializable will, in Java 8, have no inheritance, just like it didn't in earlier versions.
OK, thanks for clarifying that.
default methods break the interface paradigm and turn interfaces into abstract classes.
NOT something you want to use.
Yes, that's a widely-help view. I agree, especially because it has the "diamond" inheritance problem.
I think the designers also has doubts, but they were needed to retro-fit all the wonderful new stream support with lambdas into the existing API without breaking existing programs.
yes, which just shows how much of a kludge those are...
The fact that they had to break the core premises (no multiple inheritance at implementation level) in order to get it in should have raised a lot of red flags about wanting to put it in in the first place.