Class inside Interface

Class inside Interface

Note: It is advised to read the basics and types of inner classes before proceeding further.

The use of inner class in interface is, we can write default implementation for interface methods. In other words we can use interface as abstract class.

Another use of creating a class inside an interface is the nested class can be binded with the interface. That is, the class is tied to the interface. Programmers who use the interface only can use the class – its methods and functionality.

Programmers who implement the Manager only can use the class RoleToPlay.

Observe, in the above code, show() method is not overridden by Test as it is not implementing Outer1. In the next code it is done.

This type of tieing an interface with a class is of rare usage; the intention of organizers is mainly to organize the code and to closely associate a class functionality with an interface.

Pass your suggestions to improve the quality of this tutorial "Class inside Interface".

2 thoughts on “Class inside Interface

Leave a Reply

Your email address will not be published. Required fields are marked *