Java 8(JDK 1.8 version) introduces a new concept of default method and static method implementation in interface. We can define method inside interface using the keyword default and static.
To define a default method in java interface, we use “default” keyword with the method signature.
package test; interface A{ default void show() { System.out.println("Silan Software"); } } class B implements A { } class InterfaceExample { public static void main(String[] args) { B obj=new B(); obj.show(); } }
Silan Software
package test; interface I{ static void show() { System.out.println( "Silan Software"); } } class InterfaceExample1 { public static void main(String[] args) { A.show(); } }
Silan Software
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc