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
Explain about abstract classes in java?
How can you read an integer value from the keyword when the application is runtime in java? example?
What is a vararg?
Where is const variable stored?
Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)
What is difference between throw and throws ?
Explain covariant method overriding in java.
What is the vector class in java programming?
Can we write class inside a class in java?
What is the maximum size of list in java?
What is java literals?
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example
What are the parts of methodology?
What is a control variable example?
How we can make copy of a java object?