Home / Expert Answers / Computer Science / nbsp-overriding-methods-of-object-class-in-java-q1-create-employee-class-in-java-declare-inst-pa168

(Solved):   Overriding Methods of Object Class in Java Q1. Create Employee class in Java. Declare inst ...



Overriding Methods of Object Class in Java
Q1. Create Employee class in Java. Declare instance variables employeefirstname, e

Create main() method in the Employee Class. Declare an array EMPOBJ of Employee and allocate memory for two Employee (objects 

Overriding Methods of Object Class in Java Q1. Create Employee class in Java. Declare instance variables employeefirstname, employeelastname, employeenumber, and employeesalary. Create a constructor Employee(String, String, int, double) in the main method. The constructor receives the firstname, lastname, number, and salary as parameters when called, and assigns these values to the instance variables. You will need to use this keywords to do so. Create main() method. Create objects E1, and E2 of the employee class. To the constructor pass YOURFIRSTNAME, YOURLASTNANE, YOURNUMBER, YOURSALARY as parameters. As directed previously, the constructor Employee() will then assign these values to instance variables employeefirstname, employeelastname, employeenumber, and employeesalary. - Override hashcode() method of object class to return employeenumber when called. - Override toString() method of the object class to return employeelastname, employeefirstname, employeenumber when called. Array of Objects in Java Q2. Create Employee class in Java. Declare instance variables employeefirstname, employeelastname, employeenumber, and employeesalary. Create a constructor Employee(String, String, int, double) in the main method. The constructor receives the firstname, lastname, number, and salary as parameters when called, and assigns these values to the instance variables. You will need to use this keywords to do so. Create main() method in the Employee Class. Declare an array EMPOBJ of Employee and allocate memory for two Employee (objects). Initialize the first element of the array EMPOBJ[0], and to the constructor pass YOURFIRSTNAME, YOURLASTNAME, YOURNUMBER, YOURSALARY. Then, initialize the second element of the array EMPOBJ[1], and to the constructor pass YOURFRIENDSFIRSTNAME, YOURFRIENDSLASTNAME, YOURFRIENDSNUMBER, YOURFRIENDSSALARY. Finally, in the main() write Java statements to display the following messages. - Hello YOURLASTNAME your salary is YOURSALARY - Hello YOURFRIENDSLASTNAME your salary is YOURFRIENDSALARY - YOURFRIENDSLASTNAME and YOURLASTNAME work for the same company - Write code to compare YOURSALARY with YOURFRIENDSSALARY and state/display who is earning more.


We have an Answer from Expert

View Expert Answer

Expert Answer


// Q1) // // // // // // // // public class Employee { private String employeefirstname; private String employeelastname; private int employeenumber;
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe