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