π Introduction
To truly understand Object-Oriented Programming (OOPs) in Java, students must go beyond small examples and work on slightly detailed, real-world-like problems π‘
π This practical file includes 10 well-structured programs:
- π’ 4 Easy (but meaningful)
- π‘ 3 Medium (concept-building)
- π΄ 3 Hard (real-world application)
Each question is designed to:
- Improve logic π§
- Strengthen OOP concepts πͺ
- Prepare for viva & exams π―
π Instructions for Students
- βοΈ Write full program (class + methods + main)
- π§ Understand logic before coding
- π Add comments
- βΆοΈ Test with multiple inputs
π’ EASY LEVEL (Detailed Fundamentals)
π§ͺ Program 1: Student Management System
π Question
Create a class Student with the following details:
- name
- roll number
- marks in 3 subjects
π Perform the following:
- Calculate total marks
- Calculate average
- Display result (Pass/Fail if average β₯ 40)
- Display all details neatly
π‘ Concept
π Classes, objects, methods
π Hint
- Create methods:
calculateTotal(),calculateAverage() - Use conditional statements
- Create object in main
π§ͺ Program 2: Employee Salary System (Constructor)
π Question
Create a class Employee with:
- name
- basic salary
π Perform:
- Use constructor to initialize values
- Calculate:
- HRA = 20% of salary
- DA = 10%
- Calculate total salary
- Display all details
π‘ Concept
π Constructor + calculations
π Hint
- Use
thiskeyword - Create method
calculateSalary()
π§ͺ Program 3: Calculator using Method Overloading
π Question
Create a class Calculator that can:
- Add 2 integers
- Add 3 integers
- Add 2 double values
- Multiply 2 numbers
π Display results for all cases
π‘ Concept
π Method Overloading
π Hint
- Same method name
add() - Different parameters
- Create separate
multiply()
π§ͺ Program 4: Animal Information System (Inheritance)
π Question
Create:
- Class
Animal:- name
- age
- method
displayInfo()
- Class
Dog:- breed
- method
bark()
π Display complete dog information
π‘ Concept
π Inheritance
π Hint
- Use
extends - Call parent method
π‘ MEDIUM LEVEL (Concept Building)
π§ͺ Program 5: Vehicle System (Method Overriding)
π Question
Create:
- Class
Vehicle:- method
start() - method
stop()
- method
- Class
Caroverrides both methods - Class
Bikeoverrides both methods
π Display behavior of each vehicle
π‘ Concept
π Method Overriding
π Hint
- Use same method names
- Use
@Override - Create multiple objects
π§ͺ Program 6: Employee Hierarchy System
π Question
Create:
- Class
Person:- name, age
- Class
Employee:- salary
- Class
Manager:- department
π Display full details of manager
π‘ Concept
π Multilevel Inheritance
π Hint
- Chain inheritance
- Create display method in each class
π§ͺ Program 7: Shape Area Calculator (Abstract Class)
π Question
Create abstract class Shape:
- abstract method
area()
Create subclasses:
- Circle β calculate area
- Rectangle β calculate area
π Display area of both
π‘ Concept
π Abstraction
π Hint
- Use
abstractkeyword - Override in subclasses
- Use constructor for dimensions
π΄ HARD LEVEL (Advanced Programs)
π§ͺ Program 8: Library Management System
π Question
Create a system with:
- Class
Book:- book name
- author
- price
- Class
Library:- method to display books
- method to search book
π Perform:
- Add at least 3 books
- Display all books
- Search by name
π‘ Concept
π Objects + arrays + real-world design
π Hint
- Use array of objects
- Use loop for search
π§ͺ Program 9: Dynamic Polymorphism (Shapes Drawing)
π Question
Create:
- Class
Shapewith methoddraw() - Subclasses:
- Circle
- Rectangle
- Triangle
π Use parent reference to call methods dynamically
π‘ Concept
π Runtime polymorphism
π Hint
Shape s;
s = new Circle();
s.draw();
π§ͺ Program 10: Banking System (Real-World)
π Question
Create a banking system:
- Class
Account:- account number
- balance
- methods:
- deposit()
- withdraw()
- Subclasses:
SavingsAccount(limit withdrawal)CurrentAccount(no limit)
π Perform:
- Deposit money
- Withdraw money
- Display balance
π‘ Concept
π Inheritance + overriding + real-world logic
π Hint
- Use validation (no negative balance)
- Override withdraw method
β οΈ Common Mistakes
β Not dividing logic into methods
β Writing everything in main()
β Forgetting inheritance keywords
β Confusing overloading & overriding
π€― Common Confusions
π€ Abstract class vs normal class
- Abstract β cannot create object
- Normal β can create
π€ Overloading vs Overriding
| Overloading | Overriding |
|---|---|
| Compile-time | Runtime |
πΌ Viva Questions
β What is constructor?
π Initializes object
β What is inheritance?
π Reusing parent class properties
β What is polymorphism?
π Same method, different behavior
β What is abstraction?
π Hiding implementation
π― Final Advice
βοΈ Practice each program
βοΈ Write full code
βοΈ Understand logic
βοΈ Be ready to explain in viva
π Conclusion
This practical file now contains meaningful and slightly real-world programs π―
π If you complete these:
- Your OOP concepts will be crystal clear πͺ
- Youβll be ready for exams & interviews π
π₯ One-Line Summary
π βPractice detailed OOP problems to truly master Java.β
π» Happy Coding! π
Consistency + Practice = Success π₯