Breadcrumb

  • Java SE 8: Implementing Default Methods in Interfaces

    Prior to Java SE 8, interfaces in Java could contain only method declarations and no implementations, and any nonabstract class implementing the interface had to provide the implementation. This limitation made it almost impossible to extend the existing interfaces and APIs. To overcome this limitation, a new concept, called default methods, is introduced in Java SE 8. The default methods are fully implemented methods in an interface, and they are declared by using the keyword default. Because the default methods have some default implementation, they help extend the interfaces without breaking the existing code.

    Duration: 45 minutes

    This content is intended for the following job role(s): Java - Core Java SE Developer

    Release Date: 05-AUG-2014

    Created by: Anjana Shenoy

Reviews (1)

  • 10.1 years ago
    manisharma.cs
    than , i think no any difference in Abstract class and interface.
    • anjana.shenoy
      10.1 years ago
      Thanks, Reg difference between abstract classes and interfaces, my 2 cents: They two are still different in Java 8: Abstract class can have a constructor. Abstract classes are more structured and can hold a state. The main purpose of default methods is backward compatibility after introduction of new features (as lambda functions) in Java 8.Default methods are to add external functionality to existing classes without changing their state. And abstract classes are a normal type of inheritance, they are normal classes which are intended to be extended.
    • p.kabiito
      10 years ago
      This tutorial is the best so far, Please furnish us with more an ide such Netbeans. Well done.
    • anjana.shenoy
      10 years ago
      Thank you!

Buttons