Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by local variable and instance variable?

987


what is the difference between preemptive scheduling and time slicing? : Java thread

983


Can we have any code between try and finally blocks?

973


What is string builder in java?

958


What is the difference between the ">>" and " >>>" operators in java?

940


Which package is used for pattern matching with regular expressions?

1059


do I need to use synchronized on setvalue(int)? : Java thread

963


Which programming language is best in future?

899


What is oop in java?

969


How do you create a sop?

949


What exceptions occur during serialization?

1039


Can we make constructors static?

1182


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

1117


What is Applet Stub Interface ?

2432


What are accessor methods in java?

956