Skip to content

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

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

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

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages