Default Method

Need for default method-

Without effecting implementation classes if we want to add new method to the interface then we can do this with default interface.


Output: Default Method

Suppose if we want to provide new implementation then we can do this as well.

This can be done as below:

Now if we compile and run the above code below is the output that we will get:

Output: Own new Implementation


Comments are closed