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 ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a vararg?

760


What is data and its types?

781


How do you find the maximum number from an array without comparing and sorting?

886


What checkbox method allows you to tell if a checkbox is checked?

782


EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.

8915


What is the difference between serializable and externalizable interfaces?

809


If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

1021


What is the driver class?

772


How do you check whether the list is empty or not in java?

758


What is the length of a string?

760


What do you mean by local class?

770


Discuss different types of errors that generally occur while programming.

808


How do you create a first line indent?

748


What's the access scope of protected access specifier?

792


How many digits is int32?

743