Question: Create a new class called Lab3 with a main method. Task 1: Create a class called Person that have the following protected instance variables: String

 Create a new class called Lab3 with a main method. Task

Create a new class called Lab3 with a main method. Task 1: Create a class called Person that have the following protected instance variables: String Name long ID int age This class should also have the following methods: A default constructor. A second constructor that takes the following three parameters ( String Name, Long ID, int age) and assign their values to Name, ID and age instances variables respectively. Define setter and getter methods for each instance variable. You need to override toString() method to make sure that the method returns person's information (use a suitable format). Task 2: Create a class called Employee which contains: String jobType. double salary. Person person. This class should also have the following methods: A constructor that takes the following five parameters ( String Name, Long ID, int age, String jopType, double salary) and assign their values to person, jobType and salary instances variables respectively. You need to invoke the person's constructor within the created constructor. A default constructor that invoke the parametrize constructor with the default values. Define setter and getter methods for each instance variable. You need to override toString() method to make sure that the method returns employee's information (use a suitable format and invoke the Person toString() method). Task 3: In the main method, create two objects from the type employee (emp1 and emp2). Then conduct the following tasks: 1. use the second contractor to assign values to the instance variables. 2. Use toString() method to print the employee's information

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!