Menu

JAVA program to implement multi level inheritance


class A {
String getName(){
return "Gagan";
}
}
class B extends A {
int getAge() {
return 20;
}}
class C extends B {
String getAddress(){
return "A/1,India";
}}
class D extends C {
void print() {
System.out.println(getName());
System.out.println(getAge());
System.out.println(getAddress());
}}
class main{
public static void main(String args[]){
D obj1=new D();
obj1.print();
}}

No comments:

Post a Comment