Tuesday, 13 October 2015

Java Interface example


public class First {

public static void main(String[] args) {
// TODO Auto-generated method stub
Third obj = new Second();
Four obj1 = new Second();
obj.F();
obj.S();
obj1.F();
obj1.M();
obj1.S();
obj1.T();
}

}


public class Second implements Four {
public void F(){
System.out.println("F");
}
public void S(){
System.out.println("S");
}
public void T(){
System.out.println("T");
}
public void M(){
System.out.println("M");
}

}



public interface Third {
void F();
void S();
}

interface Four extends Third{
void T();
void M();
}


output:-
F
S
F
M
S
T

No comments:

Post a Comment