Question
In java programming, create a class named as person. From person class make a class named as employee. Make a class Manager inherit from Employee.Make
In java programming, create a class named as person. From person class make a class named as employee. Make a class Manager inherit from Employee.Make a class Executive inherit from Manager. Add an instance variable, named regionCode, of type String. Supply a method toString that prints the executive's name, department, salary and region code. Supply appropriate toString methods for all classes. Could you please use the belows for each classes.
Person Class:
private string name
public person (string name)
public setName(String name):void
public getName():String
public toString():String
Employee class:
private int salary
public Employee(String name, int salary):void
public setSalary(int salary):void
public getSalary():int
public toString():String
Manager Class:
private string department
public Manager(String name, int Salary, String Department)
public setDepartment(String department):void
public getDepartment():String
public toString():String
Executive Class:
private string regionCode
Public Executive(String name, int salary, String department, String RegionCode)
public toString():String
Please contruct the classes according to the driver code below:
public class Driverone { public static void main(String[] params) { Person person = new Person("Jack"); System.out.println(person.toString()); Employee employee = new Employee("Jack", 5000); System.out.println(employee.toString()); Manager manager = new Manager("John", 12000, "Sales" ); System.out.println(manager.toString()); Executive executive = new Executive("Mary", 18000, "HumanResource", "Abcd85" ); System.out.println(executive.toString());}}
Expected output: (When run the main code, the belows should be written in row.)
1. His/Her name is Jack.
2.1 His/Her name is Jack.
2.2 He/she gets 5000 salary
3.1 His/Her name is John.
3.2 He/she gets 12000 salary
3.3 His/Her department is Sales
4.1 His/Her name is Mary.
4.2 He/she gets 18000 salary
4.3 His/Her department is Human Resource
4.4 His/Her region code is Abcd85
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started