answersLogoWhite

0

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 "Vijay";

}

}

public class B extends A {

public int getAge() {

return 24;

}

}

public class C extends B {

public String getAddress(){

return "Utter Pradesh,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:

Vijay

24

Pradesh,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.

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: Write program java explain use abstract class multilevel inheritance?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

You want multilevel inheritance program in java?

A Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class. Ex: public class Automobile {…} Public class Car extends Automobile {…} Public class Ferrari extends Car {…} This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.


Example of multilevel inheritance program in java having HAS-A relation?

Just create a class that has two fields of object type. For example, to store data about a person, you might store a name (String object) and a birth date (Date or Calendar object).


Type of inheritance?

There are 2 Types of genetic Inheritance. 1. Polygenic inheritance, also known as quantitative or multi-factorial inheritance refers to inheritance of a phenotypic characteristic (trait) that is attributable to two or more genes and their interaction with the environment. Polygenic traits do not follow patterns of Mendelian inheritance (qualitative traits). Instead, their phenotypes typically vary along a continuous gradient depicted by a bell curve. Eye color and skin color are both polygenetic traits. 2. Monogenic inheritance is controlled by a single gene, as opposed to multigenic.


Can you explain the program of Fibonacci series in c?

You mean you have written a program, but you don't understand it? Well, how could I explain it without seeing it?


What are abstract classin java?

An Abstract class is a special kind of class that cannot be instantiated. It has one or more methods which are not implemented in the class. These methods are declared abstract and they do not contain any code inside them.Ex:abstract class Parent {public abstract String getSon();public abstract String getDaughter();........//More methods that contain specific behaviour/code in them}The above is an abstract class "Parent" that has a lot of functionality but it has declared two abstract methods which have no code inside them. Any class that has one or more abstract methods has to be abstract. This abstract class cannot be instantiated.i.e., the below piece of code will not work. The code will not even compile.Parent object = new Parent();Purpose of Abstract Classes:Abstract classes are generally used where you want an amount of behaviour to be used by the class that extends the abstract class while at the same time giving options to the child class to provide a certain amount of behaviour itself.A Child Class extending the Abstract Class:public class Child extends Parent {public String getSon() {return "Sons Name";}public String getDaughter(){return "Daughters Name";}...... //Code specific to the Child class}