Answer the following parts reguarding default methods This i
Answer the following parts reguarding default methods. This is for Java. Program used is NetBeans (I don\'t know if this matters or not)
a) How to create a default method
b) How to use a default method in a class that implements an interface
Solution
\'default\' method is only supported in java 8.
It is created as shown below:
public interface <interface_name> {
default void method_name(){
....
....
....
}
}
using a default method in a class that implements an interface:
public class cl implements <interface_name> {
default void method_name(){
// overriding
}
}
