What is the multilevel inheritance. and also give the Example
of it ?

Answer Posted / fatima deshmukh

Multilevel inheritance is a java feature where the
properties of a class are inherited by a class which extends
one class and which extend its features...

Example:

public class A {
public String getName(){
return "Fatima";
}
}

public class B extends A {
public int getAge() {
return 25;
}
}

public class C extends B {
public String getAddress(){
return "Panvel,Navi Mumbai India";
}
}

public class D extends C {
public void print {
System.out.println(getName());
System.out.println(getAge());
System.out.println(getAddress());
}
}

This method would print the following in the console:
Fatima
25
Panvel, Navi Mumbai, India

Here in class D you are calling methods that are available
inside classes A, B & C. Though D extends only class C, it
would in turn inherit the properties of the classes extended
by C and its parents.

This is multi level inheritance.

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of array are there?

736


How many ways can we create the string object?

768


How to sort an array from smallest to largest java?

777


Why java uses the concept of the string literal?

755


What is a copy constructor in java?

811


Explain java coding standards for interfaces?

849


How long will it take to learn java?

732


Can a main method be declared final?

796


Is void a data type in java?

723


Why do we create threads in java?

802


When will we prefer to use set and list in java and why?

712


What is a boolean field?

724


Do you know why doesn't the java library use a randomized version of quicksort?

740


What is the diffrence between inner class and nested class?

813


when to use ArrayList and when to use HashMap in webApplication.

4233