multilevel inheritance
import java.io.*;
public class Employee
{
int eid;
String ename;
void tostring()
{
System.out.print("Enter Your ID:");
eid=Integer.parseInt(in.readLine());
System.out.print("Enter Your Name:");
ename=in.readLine();
}
}
public class Manager extends Employee
{
float commission;
void ComputeSalary()
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Salary:");
Salary=Float.parseFloat(in.readLine());
float tsalary=commission+salary;
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class SalesPerson extends Manager
{
int sales;
void ComputeSalary()
{
toString();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Sales:");
sales=Integer.parseInt(in.readLine());
float tsalary=commission+sales;
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class Wage extends salesPerson
{
int hr,rate;
void ComputeSalary()
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Working Hours:");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter Your Salary Rate/per Hour:Rs.");
rate=Integer.parseInt(in.readLine());
float tsalary=commission+(hr*rate);
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class iheritannce
{
public static void mai(String args[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
Employee A=new Employee();
Manager B=new Manager();
SalesPerson C=new SalesPerson();
Wage D=new Wage();
A.ComputeSalary();
B.ComputeSalary();
C.ComputeSalary();
D.ComputeSalary();
}
}
View Answers
May 2, 2012 at 12:04 AM
hey,,,,,,plz anyone help me..
May 2, 2012 at 10:42 AM
import java.io.*;
class Employee {
int eid; String ename;
DataInputStream in=new DataInputStream(System.in);
float salary;
void tostring()throws Exception
{
System.out.print("Enter Your ID:");
eid=Integer.parseInt(in.readLine());
System.out.print("Enter Your Name:");
ename=in.readLine();
}
void ComputeSalary()throws Exception
{
toString();
}
}
class Manager extends Employee {
float commission;
void ComputeSalary()throws Exception
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Salary:");
salary=Float.parseFloat(in.readLine());
float tsalary=commission+salary;
System.out.print("Your Total Salary:Rs."+tsalary);
}
} class SalesPerson extends Manager { int sales;
void ComputeSalary()throws Exception
{
toString();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Sales:");
sales=Integer.parseInt(in.readLine());
float tsalary=commission+sales;
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
class Wage extends SalesPerson { int hr,rate;
void ComputeSalary()throws Exception
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Working Hours:");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter Your Salary Rate/per Hour:Rs.");
rate=Integer.parseInt(in.readLine());
float tsalary=commission+(hr*rate);
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class Inheritance {
public static void main(String args[])throws Exception {
Employee A=new Employee();
Manager B=new Manager();
SalesPerson C=new SalesPerson();
Wage D=new Wage();
A.ComputeSalary();
B.ComputeSalary();
C.ComputeSalary();
D.ComputeSalary();
}
}
Related Tutorials/Questions & Answers:
multilevel inheritancemultilevel inheritance import java.io.*;
public class Employee
{
int eid;
String ename;
void tostring()
{
System.out.print("Enter Your ID:");
eid=Integer.parseInt(in.readLine());
System.out.print("Enter Your
Multilevel inheritance - Java BeginnersMultilevel inheritance Dear Sir,
I'm posting you another question for which I need a more explanatory java coding(A lengthy one with more classes... to
multilevel inhertance "
Thank You
Advertisements
Multilevel Inheritance in javaMultilevel Inheritance in java
We are going to discuss about
multilevel inheritance in java. The
Multilevel
inheritance is inherit of classes more than two classes. We use
multilevel
inheritance to create one-to-one ladder. "
Java : Multilevel InheritanceJava :
Multilevel Inheritance
This section contains concept of
multilevel Inheritance in java.
Multilevel Inheritance :
In
multilevel inheritance more than... can say
multilevel inheritance create
one-to-one ladder.
Now you can access
Inheritance program in java and
Multilevel Inheritance in Java.
Inheritance is an OOPS (Object Oriented...
Multilevel inheritance
Hierarchical
inheritance
ADS_TO_REPLACE_2... display(){
System.out.println("B");
}
}
Multilevel Inheritance
Java
inheritanceinheritance how does one implement
inheritance in java
multilevel inhertencemultilevel inhertence package start;
class A
{
protected void a() //a method in A
{
System.out.println("Class A");
}
}
class B extends A
{
public B
inheritanceinheritance hi.. pleaseeeeee i need a quick help(answer) in creating aprogrm in java by using
inheritance for car in such away that .... Car is parent class and both of Private and Public Car extends it then both of Bus
Inheritance Inheritance
Multilevel Inheritance
Pictorial Representation of Simple...
Simple
Inheritance
Multilevel Inheritance
Simple
Inheritance...; }
}
Multilevel Inheritance Inheritance Inheritance
Multilevel Inheritance
Pictorial Representation of Simple...
Simple
Inheritance
Multilevel Inheritance
Simple
Inheritance
When...;);
}
}
Multilevel Inheritance Concept of Inheritance in Java as single
inheritance or one level
inheritance.
Multilevel Inheritance..., the former becomes the parent class for later.
Multilevel inheritance can go up...Concept of
Inheritance in Java
Concept of
Inheritance in Java is considered
Inheritance in Java
There are two types of
inheritance in Java:
Simple
Inheritance
Multilevel... and it's parent class.ADS_TO_REPLACE_2
Multilevel Inheritance:
Multiple...
Inheritance, one of the important concepts of Object Oriented Programming
multiple inheritance.multiple
inheritance. hello,
can java support multiple
inheritance???
hi,ADS_TO_REPLACE_1
java does not support multiple
inheritance Inheritance in Java with example, they are:
Simple
inheritance
Multilevel inheritance.
Hierarchical
inheritance
Note...(25,26);
text.Show();
}
}
Output:
Multilevel inheritance: The
Multilevel inheritance is
inheriting features of more than one class
multiple inheritancemultiple inheritance why java doesn't support multiple
inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
Java inheritance Java
inheritance can the child access protected content of the parent if the child is in a different project
If you have considered different project as different package then the child cannot access the content
Multiple InheritanceMultiple Inheritance Why Java Doesn't have Multiple
Inheritance It is Advantage or Disadvantage.........
Hi Friend,
When we extends... and inconsistencies Java does not support Multiple
Inheritance.
Thanks
Multiple InheritanceMultiple Inheritance All are saying java doesn't support multiple
inheritance but by default Object class is super class for all the user defined... class so java any how do multiple
inheritance? Can you please explain
Inheritance Example In Java types of
inheritance. These are
as follows :
Single
Inheritance
Multilevel...
Inheritance Example In Java
In this section we will read about the
Inheritance using a simple example.
Inheritance is an OOPs feature that allows to inherit
Inheritance question?Inheritance question? Q3)Create a class hierarchy as Company extended by AccountsDepartment.
AccountsDepartment extended by AccountsReceivable and AccountsPayables.
The Company performs following operations.
(1
Inheritance question?Inheritance question? Q3)Create a class hierarchy as Company extended by AccountsDepartment. AccountsDepartment extended by AccountsReceivable and AccountsPayables. The Company performs following operations. (1
Inheritance in Spring Inheritance in Spring
Inheritance Demo, In the example given below we are going
to tell
about the
inheritance in the Spring framework. By
inheritance we mean a way
Inheritance other features
like creation and implementation of the object,
Inheritance etc...;
float p,
q;
...(){
return(p *
q);
Inheritance in java - Java BeginnersInheritance in java I want a example program using the concept of (single and multiple)
inheritance. Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/language/inheritance.shtml
Thanks
creating inheritance of cars creating
inheritance of cars hi ... please help me in creating
inheritance between some types of cars like
car that is parent and both of private car and public car are extends it then bus and truck extends public car
Maven's order of inheritanceMaven's order of inheritance hello,
What is Maven's order of
inheritance?
hii,ADS_TO_REPLACE_1
1.parent pom
2.project pom
3.settingsADS_TO_REPLACE_2
4.CLI parameters
multiple inheritance - Java Beginnersmultiple inheritance Why java does not support Multiple
Inheritance? First of all the question is wrong the correct one is.........
Q)why java classes does not support Multiple
Inheritance?
JAVA CLASSES ONLY
Does Java support multiple Inheritance?Does Java support multiple
Inheritance? Hi,
I am beginner in Java and trying to implement multiple
inheritance in Java. But could not find any example.
Does Java support multiple
Inheritance?
Thanks
Hi,
Good
Does Java support multiple Inheritance?Does Java support multiple
Inheritance? Hi,
I am beginner in Java and trying to implement multiple
inheritance in Java. But could not find any example.
Does Java support multiple
Inheritance?
Thanks
Hi,
Good
Does Java support multiple Inheritance?Does Java support multiple
Inheritance? Hi,
I am beginner in Java and trying to implement multiple
inheritance in Java. But could not find any example.
Does Java support multiple
Inheritance?
Thanks
Hi,
Good
Inheritance - Java BeginnersInheritance pls help me!!!
Question:
write an
inheritance hierachy for classes Quadrilateral,Trapezoid,Parallelogram, Rectangle and Square. Use Quadrilateral as superclass. make hierachy as deep as possible. Specify
Java Inheritance Concept.Java
Inheritance Concept. Yesterday i got confused with following question in an aptitude exam.
Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Inheritance java ExampleInheritance java Example How can we use
inheritance in java program?
class Animal {
public void eat(String str... of
inheritance.
Inheritance is a way of establishing a subtype from an existing object