multilevel inheritance

Ads
 

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();
        }
        }

May 2, 2012 at 10:43 AM

For more information, visit the following link:

Java Inheritance

Ads









Related Tutorials/Questions & Answers:
multilevel inheritance
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
Java : Multilevel Inheritance
Java : 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
Advertisements
Multilevel Inheritance in java
Multilevel 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. "
Inheritance program in java
and Multilevel Inheritance in Java. Inheritance is an OOPS (Object Oriented... supports three types of inheritance: Simple inheritance Multilevel...;); } } Multilevel Inheritance Java does not support Multiple Inheritance DIRECTLY
inheritance
inheritance  how does one implement inheritance in java
inheritance
inheritance  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
multilevel inhertence
multilevel inhertence  package start; class A { protected void a() //a method in A { System.out.println("Class A"); } } class B extends A { public B
Inheritance,Inheritance in Java,Java Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of inheritance. When
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of inheritance. When
ModuleNotFoundError: No module named 'multilevel-mesa'
ModuleNotFoundError: No module named 'multilevel-mesa'  Hi, My... named 'multilevel-mesa' How to remove the ModuleNotFoundError: No module named 'multilevel-mesa' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'multilevel-panels'
ModuleNotFoundError: No module named 'multilevel-panels'  Hi, My... named 'multilevel-panels' How to remove the ModuleNotFoundError: No module named 'multilevel-panels' error? Thanks   Hi, In your
Inheritance
; Multilevel Inheritance Pictorial Representation of Simple and Multilevel... Multilevel Inheritance Simple Inheritance When a  subclass is derived...;} } Multilevel Inheritance It is the enhancement of the concept of inheritance. When
Concept of Inheritance in Java
. Multilevel Inheritance In Multiple Inheritance, a parent class is extended.... Multilevel inheritance can go up to any number of levels. Java does not support...Concept of Inheritance in Java Concept of Inheritance in Java is considered
Inheritance in Java
of inheritance in Java: Simple Inheritance Multilevel Inheritance... class. Multilevel Inheritance: Multiple Inheritance is when a subclass is derived... for it's just above (parent) class. Multilevel inheritance can go up to any number
Inheritance in Java with example
inheritance Multilevel inheritance. Hierarchical inheritance Note: 1. subclass...: Multilevel inheritance: The Multilevel inheritance is inheriting features... be achieved by interface. In this example we have used multilevel inheritance
ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu'
ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu...: ModuleNotFoundError: No module named 'binomia_translatable_multilevel_menu' How to remove the ModuleNotFoundError: No module named 'binomia_translatable_multilevel
javascript inheritance framework
javascript inheritance framework  javascript inheritance framework
multiple inheritance
multiple 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 Inheritance
Multiple 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 Inheritance
Multiple 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
. These are as follows : Single Inheritance Multilevel Inheritance...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
inheritance
Inheritance
inheritance
inheritance
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
ModuleNotFoundError: No module named 'inheritance'
ModuleNotFoundError: No module named 'inheritance'  Hi, My Python... 'inheritance' How to remove the ModuleNotFoundError: No module named 'inheritance' error? Thanks   Hi, In your python environment

Ads