Question: (use java) Create a class Employee name, salary default constructor overloaded constructor toString Method Create second class Department name, array of employee class type, count

(use java)

  1. Create a class Employee
  • name, salary
  • default constructor
  • overloaded constructor
  • toString Method
  1. Create second class Department
  • name, array of employee class type, count
  • default constructor
  • overloaded constructor
  • addEmployee(name, salary) method
  1. Create third class Test
  • main
  • create object of department class
  • call addEmployee method and add 5 employees
  • by giving name and salary value
  • Print all the employee details using loop

In the previous program add one more static integer variable in Department

class called MAX = 10

In default construcor of Department class apart from setting the department

name create an of Employee object and set the lenght of array to MAX

In the AddEmployee method of Department class check whether the array of

Employee object array is full or not. If it is full display a message

called 'Class is full', otherwise add the Employee to the array

In the Department class also add toString method that will display all the

employees details present in the Employee array object

In the test class create an object of Department class

Using addEmployee method add 10 Employee

Also check whether it is adding 11 employee or not

Finally display the all the added employee details by calling toString method

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!