Search Interview Questions
| More than 3000 questions in repository.|
There are more than 900 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Interview Questions and Answers|
|Ans. Earlier any class implementing an interface was supposed to implement all methods declared in an interface. There was no place for optionally implementing all or subset of methods.Though we have abstract classes wherein we could have provided such a mechanism by declaring some methods as abstract while providing definition for some. But as Abstract classes have a body and are comparatively heavier than interfaces and interfaces associate closely to the concept of providing interfacing than abstract classes, Java might have though of providing optional implementation for default methods. This way same interface can be reused in variety of ways rather than making copies of an interface to suit different needs.|
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  java 8   java8  interface default methods  default methods Asked in 6 Companies|
|Why can't we have diamond problem with interfaces ?|
|Does java allow implementation of multiple interfaces having Default methods with Same name and Signature ?|
|What are Default Methods ?|
|Can we have a private default method ?|
|If there is a conflict between Base Class Method definition and Interface Default method definition, Which definition is Picked ?|
|Can we have a default method without a Body ?|
|Can we have a default method definition in the interface without specifying the keyword "default" ?|
|Can a class implement two Interfaces having default method with same name and signature ?|
|What If we make the method as abstract in another Interface ?|