Versions

[{“Name”:“Java SE 8”,“GroupName”:null},{“Name”:“Java SE 9 (Early Access)”,“GroupName”:null}]

Introduction

Default Method introduced in Java 8, allows developers to add new methods to an interface without breaking the existing implementations of this interface. It provides flexibility to allow the interface to define an implementation which will be used as default when a class which implements that interface fails to provide an implementation of that method.

Syntax

Remarks

Default methods

Static methods

Below is a table summarizing the interaction between sub-class and super-class.

-| SUPER_CLASS-INSTANCE-METHOD | SUPER_CLASS-STATIC-METHOD —— | —— | ——SUB_CLASS-INSTANCE-METHOD | overrides | generates-compiletime-error

SUB_CLASS-STATIC-METHOD | generates-compiletime-error | hides