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

how can i connect to database in a applet ?

1 Answers  


how to create daemon thread in java?

0 Answers  


What is the difference between super class & sub class?

0 Answers  


Why java is said to be pass-by-value ?

0 Answers  


What is this () in java?

0 Answers  






what models are available for event handling?

1 Answers  


What is externalizable interface?

0 Answers  


What is type inference in java8?

0 Answers  


What is a boolean in java?

0 Answers  


What is the primary benefit of encapsulation?

0 Answers  


What is outofmemoryerror in java?

0 Answers   Cyient,


What is meant by polymorphism?

0 Answers  


Categories