Java Help
Sunday, 8 March 2020
Java 8 - Interface and Class
Please check one of the features of Java 8 related to the Interface and Class
Program :
public class HelloWorld{ public static void main(String []args){ Child c = new Child(); c.show();// this will print "Class" } } interface I { default void show(){ System.out.println("Interface"); } default void showAgaing(){ // we define multimple default method under Interface System.out.println("Interface again"); } } class C { public void show(){ System.out.println("Class"); } } class Child extends C implements I{ // public void show(){ // System.out.println("Child"); // } }
Code Link
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment