What was the driving force to introduce default methods in Interfaces wef from Java 8 ?
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers

 Q1. What was the driving force to introduce default methods in Interfaces wef from Java 8 ?Core Java
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


Related Questions

 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 ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: