Skip to content

DurgeshOnStack/Employee_PerformanceTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Employee Encapsulation and Method Overriding in Java πŸ“Œ Project Overview This mini project demonstrates the importance of Encapsulation in Java and shows how method overriding works in an inheritance hierarchy. It compares two approaches to handling employee data: Without Encapsulation – where class fields are openly accessible and can be modified directly. With Encapsulation – where sensitive data is protected using private variables and controlled access through getters and setters. The project also includes a logic-based method to evaluate employee performance based on salary and bonus. 🧠 Concepts Covered: Encapsulation (data hiding) Inheritance Method Overriding Access Modifiers Basic conditional logic

Object-Oriented Programming (OOP) principles in Java:

πŸ—οΈ Project Structure EmployeeEncapsulation/ β”‚ β”œβ”€β”€ Employee.java // Non-encapsulated class β”œβ”€β”€ SecureEmployee.java // Encapsulated subclass with method overriding └── Main.java // Driver class with main() method

🧩 Class Description 1️⃣ Employee (Non-Encapsulated Class)

Fields (default access): String name double salary

Method: displayDetails() Displays basic employee information.

➑️ Fields can be modified directly, showing lack of data protection.

2️⃣ SecureEmployee (Encapsulated Subclass)

Private Field: double bonus Public Methods: Getter and Setter for bonus Overridden displayDetails() to include bonus

performanceStatus() method with logic:

Salary + Bonus β‰₯ 100000 β†’ Excellent Performer

Salary + Bonus β‰₯ 50000 β†’ Good Performer

Else β†’ Needs Improvement

➑️ Demonstrates proper encapsulation and controlled data access.

⌨️ Input Format EmployeeName Salary Bonus

Example Input Riya 45000 10000

πŸ“€ Output Format Without Encapsulation: <displayDetails() output>

With Encapsulation (Overridden): <displayDetails() output>

Performance Status: <performanceStatus() output>

Example Output Without Encapsulation: Name : Riya Salary : 45000.0 (Fields can be modified directly!)

With Encapsulation (Overridden): Name : Riya Salary : 45000.0 Bonus : 10000.0

Performance Status: Good Performer

🎯 Key Learning Outcome Understand why encapsulation is essential for data security. See how method overriding allows subclasses to extend or modify behavior. Learn how logic-based methods improve program functionality. Gain practical exposure to real-world OOP design principles. πŸš€ How to Run the Project Clone the repository Open the project in any Java IDE (Eclipse / IntelliJ / VS Code) Compile and run the Main.java file Provide input as specified

πŸ“š Suitable For Java beginners OOP concept practice College mini projects Interview preparation

πŸ‘€ Author

Durgesh Tiwari Java Full Stack Trainee Naresh IT,Hyderabad

About

A Java mini project demonstrating core OOP principles such as encapsulation, inheritance, and method overriding. The project compares non-encapsulated and encapsulated class designs to show the importance of data hiding and includes logic-based employee performance evaluation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages