A default method in Java can be specifically invoked by using the interface name followed by the method name. For example, if we have an interface named "MyInterface" with a default method "myMethod", we can invoke the default method as follows:
MyInterface obj = new MyClass();
obj.myMethod(); // Invokes the default method
Here, we have created an object of a class ("MyClass") that implements the "MyInterface". We can then use this object to invoke the default method "myMethod".
Asked: 2021-07-24 11:00:00 +0000
Seen: 8 times
Last updated: Jun 10 '21