answersLogoWhite

0


Best Answer

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

Example:

public class A {

public String getName(){

return "Rocky";

}

}

public class B extends A {

public int getAge() {

return 24;

}

}

public class C extends B {

public String getAddress(){

return "North Carolina, USA";

}

}

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:

Rocky

24

North Carolina, USA

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.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

public class A {

...

}

public class B extends A{

...

}

public class C extends B {

...

}

This is a simple hierarchical inheritance. The class C extends class B but since the class B extends A, class C indirectly extends class A also.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

This is the scenario wherein your java code exhibits traits of more than one of the inheritance types:

Public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

The above is a combination of both single and multiple inheritance.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Example of Hierarchical Inheritance program in java?

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Simple hierarchical inheritance program in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the names of different part of simple java program?

NO!


What is inheritance in core java?

Inheritance is the ability to derive and use other class's attribute and behavior. It results in the reduction of coding lines and the reuse of same codings in some other places. It is an important concept for java and makes to program easily...


How can you write multiple inheritance program in java?

Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }


What does java not support?

Java does not support multiple inheritance.......


What is ambiguity in multiple inheritance?

Java does not support multiple inheritance


What kind of inheritance is not allowed in java?

Java does not allow the multiple inheritance of concrete classes, though it does allow a "hybrid" inheritance of one concrete class and multiple interfaces.


What is problem in multiple inheritance?

Java does not support direct multiple Inheritance. Harder to implement, not every language support it: C++ does, Java does not.


Give the structure of multiple inheritance?

Java does not support multiple inheritance. It is done with the help of interfaces in java. a class can implement n number of interfaces, thus showing multiple inheritance. but a class cannot extend multiple classes in java.


Java program to demonstrate multiple inheritance?

Inheritance is one of the building blocks of Java and it is used extensively in all java based applications. Inheritance is everywhere in Java. I can't think of one java project that I worked on, where inheritance wasn't used. Inheritance is the feature wherein the properties/qualities of a parent class or interface is used in the child class. Both Classes & Interfaces are used in Java Inheritance


What is public inheritance in java?

Inheritance is a Java feature by which we can reuse code and programming logic from one class in another class. We implement Inheritance using the extends keyword.Ex: public class Ferrari extends Car {…}Here the Ferrari Class will extend features from the Car Class.This is Inheritance. The different types of Inheritance are:Single InheritanceMulti-Level InheritanceMultiple Inheritance (Java supports only Partial Multiple Inheritance) andHybrid Inheritance


How ploymorphism and inheritance is different from that in Java and c plus plus?

C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.


What do you mean by multithread program in java?

A Program in Java that spawns multiple threads is called a multithreaded program in Java.