Multilevel Inheritance and Function Overriding in Java
package oop;
public class Oop {
public static class A{
void func(){
System.out.println("Function of A");
}
void func1(){
System.out.println("Function of A");
}
}
public static class B extends A{
void func(){
System.out.println("Function of B");
}
void func1(){
super.func1();
System.out.println("Function of B");
}
}
public static class C extends B{
void func(){
System.out.println("Function of C");
}
void func1(){
super.func1();
System.out.println("Function of C");
}
}
public static void main(String[] args) {
C obj4=new C();
obj4.func();
obj4.func1();
}
}
public class Oop {
public static class A{
void func(){
System.out.println("Function of A");
}
void func1(){
System.out.println("Function of A");
}
}
public static class B extends A{
void func(){
System.out.println("Function of B");
}
void func1(){
super.func1();
System.out.println("Function of B");
}
}
public static class C extends B{
void func(){
System.out.println("Function of C");
}
void func1(){
super.func1();
System.out.println("Function of C");
}
}
public static void main(String[] args) {
C obj4=new C();
obj4.func();
obj4.func1();
}
}
Post a Comment