Launch your tech mastery with us—your coding journey starts now!
Course Content
Array Handling
0/1
String Handling
0/1
Wrapper Classes
0/1
Collections in Java
0/1
Packages
0/1
File Handling
0/1
Multithreading
0/1
Java Networking
0/1
Core Java

🎯 If you’re preparing OOPS concepts for university exams, here’s a collection of exercises (with increasing difficulty) that touch all the major OOPS concepts in Java. These are highly exam-relevant and will also boost practical understanding 👇

📝 OOPS Practice Exercises in Java (University/College Level)


1️⃣ Classes and Objects

Easy-level, foundation concept

  • Write a class Student with attributes: name, rollNumber, and marks.
    Create objects of Student and display their details.

  • Create a class Car with properties brand, model, and price.
    Write a method displayInfo() to show car details.


2️⃣ Encapsulation

Testing getters & setters

  • Create a class BankAccount with private variables: accountNumber, balance.
    Provide getter and setter methods.
    Write code to deposit money and check balance.


3️⃣ Inheritance

Shows reusability & parent-child relation

  • Create a class Person with attributes name, age.
    Derive a subclass Employee with attributes salary and designation.
    Demonstrate inheritance by creating objects.

  • Create a base class Shape with method area().
    Extend classes Circle and Rectangle that override area() method.


4️⃣ Polymorphism

Method Overloading & Overriding exercises

  • Overloading: Create a class Calculator with methods add(int, int) and add(double, double). Show method overloading.

  • Overriding: Create a class Animal with method sound().
    Subclass Dog and Cat to override sound().


5️⃣ Abstraction

Abstract classes practice

  • Create an abstract class Vehicle with abstract method start().
    Implement it in subclasses Car and Bike.


6️⃣ Interface

Multiple inheritance via interface

  • Create an interface Payment with method pay().
    Implement it in classes CreditCardPayment and UPIPayment.

  • Create two interfaces Camera and MusicPlayer.
    Create a class SmartPhone that implements both.


7️⃣ Constructor & ‘this’ keyword

Frequently asked in exams

  • Write a program to demonstrate constructor overloading in a Book class.

  • Use this keyword to differentiate between class variables and method parameters.


8️⃣ Static Keyword

Important for theory + coding

  • Create a class College with static variable collegeName.
    Show how all objects share the same static variable.

  • Write a program with a static method displayUniversity() to print a university name.


9️⃣ Real-world Mini Project (Integration of All OOPS)

📌 Often asked as long-answer/15-mark questions

  • Design an E-Commerce Application skeleton in Java:

    • Class Product (id, name, price).

    • Class Customer (id, name, email).

    • Abstract class Order with abstract method placeOrder().

    • Subclass OnlineOrder and OfflineOrder that override placeOrder().

    • Interface Payment with pay(). Implement CreditCard and UPI.

    • Demonstrate all OOPS principles in action.


🎯 Why These Are Exam-Ready?

  • Covers all four pillars: Encapsulation, Inheritance, Polymorphism, Abstraction.

  • Includes syntax-based + application-based questions.

  • Gives both small coding snippets (5–8 marks) and long coding problems (10–15 marks).