public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
Second obj = new Third();
obj.Common();
Second obj1 = new Four();
obj1.Common();
Second obj2 = new Second();
obj2.Common();
Third obj3 = new Four();
obj3.Common();
}
}
public class Second {
void Common(){
System.out.println("Second class Common");
}
}
class Third extends Second{
void Common(){
System.out.println("Third class Common");
}
}
class Four extends Third{
void Common(){
System.out.println("Four class Common");
}
}
output:-
Third class Common
Four class Common
Second class Common
Four class Common
No comments:
Post a Comment