0% found this document useful (0 votes)
2 views5 pages

Java OOP Practice Problems

The document outlines a Java Object-Oriented Programming (OOP) practice problem set aimed at enhancing understanding of OOP concepts through structured levels. It includes tasks on core OOP building blocks, encapsulation, inheritance, polymorphism, abstraction, interfaces, composition, and exception handling. The suggested practice flow encourages progressive learning from basic to advanced topics.

Uploaded by

asaafbd1981
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Java OOP Practice Problems

The document outlines a Java Object-Oriented Programming (OOP) practice problem set aimed at enhancing understanding of OOP concepts through structured levels. It includes tasks on core OOP building blocks, encapsulation, inheritance, polymorphism, abstraction, interfaces, composition, and exception handling. The suggested practice flow encourages progressive learning from basic to advanced topics.

Uploaded by

asaafbd1981
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Department of Software Engineering

Java Object-Oriented Programming Practice Problem Set


Objective: Strengthen understanding of Object-Oriented Programming (OOP) concepts in Java
through level-wise and topic-wise problem-solving.

Level Focus Area


Level 1 Core OOP Building Blocks (Classes, Objects)
Level 2 Encapsulation & Constructors
Level 3 Inheritance, Polymorphism, Abstraction
Level 4 Interfaces, Composition, Exception Handling

Level 1: Beginner (Core OOP Building Blocks)


Topic: Classes and Objects
Create a class Student with attributes: name, id, and cgpa. Write methods to display student
information.

Create a Calculator class with methods for addition, subtraction, multiplication, and division.

Create a class Rectangle with length and width as attributes. Include a method to calculate and
return the area.
Level 2: Intermediate (Encapsulation & Constructors)
Topic: Encapsulation
Create a BankAccount class with private attributes and public methods deposit(), withdraw(),
checkBalance().

Create a Grade class with private marks for three subjects. Provide methods to input marks,
calculate average, and determine grade.

Topic: Constructors
Create an Employee class with attributes name, id, salary and both default and parameterized
constructors.

Create a Product class with productId, productName, and price initialized using a constructor.
Level 3: Object Relationships (Inheritance, Polymorphism, Abstraction)
Topic: Inheritance
Create a base class Vehicle and a derived class Car to demonstrate single inheritance.

Create classes Person → Employee → Manager to demonstrate multilevel inheritance.

Create Shape, Circle, and Triangle classes to demonstrate hierarchical inheritance.

Topic: Method Overloading & Overriding


Create overloaded methods in a class AreaCalculator to calculate area for different shapes.

Create Animal, Dog, and Cat classes where Dog and Cat override makeSound().

Topic: Abstraction
Create an abstract class Payment and subclasses CreditCardPayment and PayPalPayment
implementing processPayment().

Create an abstract class Shape and implement concrete Rectangle and Circle classes.
Level 4: Advanced (Interfaces, Composition, Exception Handling, Static
& Final)
Topic: Interface
Create an interface Drivable with methods start() and stop() implemented by Car and Bike.

Create interfaces Flyable and Swimmable, implement both in a class Duck.

Topic: Composition (Has-A Relationship)


Create classes Professor and Department where Department has one or more Professors.

Create a Library class containing a list of Book objects.

Topic: Exception Handling


Write a program that handles ArithmeticException when dividing by zero.

Write a program that reads a text file using BufferedReader and handles IOException.
Suggested Practice Flow
1. Solve Level 1 problems first to strengthen syntax & basic class design.
2. Move to Level 2 for understanding constructors & encapsulation.
3. Focus on Level 3 for mastering inheritance, polymorphism, and abstraction.
4. Finally, solve Level 4 problems to gain confidence with advanced OOP features.

You might also like