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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / 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

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

Answer / namrata

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:

import java.io.*;
class superclass
{
void sum(int x,int y)
{
int add;
add=x+y;
System.out.println("addition="+ add);
}
}

class subclassA extends superclass
{
void subtraction(int a, int b)
{
int sub;
sub=a-b;
System.out.println("subtraction="+sub);
}
}

class subclassB extends subclassA
{
void multiplication(int m, int n)
{
int mult;
mult=m*n;
System.out.println("multipliction="+mult);
}
}

class subclassC extends subclassB
{
public static void main(String arg[])throws IOException;
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
int p,q;
System.out.println("enter value in p");
p=Integer.parseInt(br.readLine());
System.out.println("enter value in q");
q=Integer.parseInt(br.readLine());
subclassC obj=new subclassC();
obj.multiplication(p,q);
obj.subtraction(p,q);
obj.sum(p,q);
}
}

Is This Answer Correct ?    6 Yes 1 No

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

Answer / punit chauhan

Plz send answer of this question my email -
punitchauhan22@gmail.com

Is This Answer Correct ?    8 Yes 4 No

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

Answer / guest

a multilevel inheritence is one in which there exist one base
class ,one derived class and multiple intermediate base class.

Is This Answer Correct ?    6 Yes 8 No

Post New Answer

More Core Java Interview Questions

Can you extend more than one interface?

9 Answers  


How is rounding performed under integer division?

2 Answers   Satyam,


What does arrays sort do in java?

0 Answers  


What is the memory leak in java?

0 Answers  


What is parse method?

0 Answers  






Can we have 2 main methods in java class?

0 Answers  


Can we use different return types for methods when overridden?

0 Answers  


What is space character in java?

0 Answers  


Is math class static in java?

0 Answers  


Name two subclasses of the TextComponent class?

2 Answers  


What are the application of stack?

0 Answers  


How can you share data between two thread in Java?

0 Answers  


Categories