Advanced Java Evaluation Test
Date: 8 June 2024
Q.1 Problem Statement:
You are required to design an advanced Employee Management System in Java. The system
should manage employee records and perform various operations such as adding, updating,
and displaying employee details. Additionally, it should handle specific exceptions gracefully,
support concurrent updates using multithreading with synchronization, and allow sorting of
employees based on their salaries using the Comparable interface.
Requirements:
Create a base class Person with the following attributes:
● name (String)
● age (int)
Create a derived class Employee that inherits from Person and adds the following attributes:
● employeeId (int)
● department (String)
● salary (double)
● Inside the Employee class, create a method updateEmployeeDetails(int
employeeId, String department, double salary) that contains a
method-local inner class Validator. The Validator class should validate the new
department and salary before updating the employee's details.
○ The department should be non-null and non-empty.
○ The salary should be greater than zero.
● If validation fails, the method should throw a custom exception
InvalidEmployeeDataException.
● Create a custom exception class InvalidEmployeeDataException that extends
Exception.
● Handle this exception in the updateEmployeeDetails method and display an
appropriate error message.
● Use an appropriate collection framework <Employee> to store and manage
employee records.
● Implement multithreading to allow concurrent updates to employee records.
● Ensure thread safety using synchronization when updating employee details.
● Create a class EmployeeUpdater that implements Runnable and updates employee
details concurrently.
● Implement the Comparable<Employee> interface in the Employee class to allow
sorting based on employee salary.
● Create a class EmployeeManagement with a main method.
● In the main method, demonstrate the functionality of adding, updating, and sorting
employee records.
● Handle any exceptions that occur during these operations and display meaningful
messages.
● Ensure proper encapsulation of class attributes.
● Use appropriate constructors and methods to initialize and manipulate objects.
● Implement a method displayEmployeeDetails in the Employee class to display
employee details.