Thursday 26 June 2014

Interface : static Methods

In addition to default methods, you can define static methods in interfaces. All method declarations in an interface, including static methods, are implicitly public.
interface A{
 void print();
 
 static void show(){
  System.out.println("I am in interface A");
 }
 
}

interface B extends A{
 void display();
 static void show(){
  System.out.println("I am in interface B");
 }
}

class Test{
 public static void main(String args[]){
  B.show();
  A.show();
 }
}

Output
I am in interface B
I am in interface A



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment