loading

notes projects solutions papers notes
Home About Classes Blog Ask a Doubt → Watch on YouTube
Java Basics

Understanding OOP in Java:
A Complete Guide for Class 10 Students

April 5, 2025 · 8 min read · ICSE Class 10
ISC Java Teacher
Rishikesh Shahani

Computer Applications · ICSE & ISC Board

Object-Oriented Programming (OOP) is the backbone of Java. Once you understand it, everything else in Java falls into place naturally. This guide walks through all four pillars of OOP — using simple, real-world analogies that make sense to a school student.

In this article

  1. What is OOP?
  2. Classes and Objects
  3. Encapsulation
  4. Inheritance
  5. Polymorphism
  6. Exam Tips

What is OOP?

Object-Oriented Programming is a programming paradigm built around objects. Instead of writing a long list of instructions (procedural programming), OOP organises code into self-contained units — objects — that have both data (properties) and behaviour (methods).

Think of it this way: A car is an object. It has properties (colour, brand, speed) and behaviours (accelerate, brake, turn). In Java, a Car class is the blueprint; each actual car you create is an object.

Classes and Objects

A class is a template or blueprint. An object is an instance of that class — a real, in-memory entity created from the blueprint.

public class Car {
      String color;
      int    speed;

      void accelerate() {
      speed += 10;
      System.out.println("Speed: " + speed);
      }
      }
      // Creating objects
      Car myCar  = new Car();
      Car herCar = new Car();

Here, myCar and herCar are two distinct objects, each with their own color and speed values, even though they come from the same Car class.

Encapsulation

Encapsulation means bundling data and the methods that operate on it into a single unit (the class), and hiding the internal details from the outside world using access modifiers like private.

        
          public class BankAccount {
          private double balance; // hidden from outside

          public void deposit(double amount) {
          if(amount > 0) balance += amount;
          }
          public double getBalance() {
          return balance;
          }
          }
        
      
Encapsulation is the principle of "need to know" — the outside world only sees what it needs to. Implementation details stay private.

Inheritance

Inheritance allows a new class (child) to acquire properties and methods of an existing class (parent). This promotes code reuse and creates an is-a relationship.

        
          class Animal {
          void eat() { System.out.println("Eating..."); }
          }

          class Dog extends Animal {
          void bark() { System.out.println("Woof!"); }
          }

          Dog d = new Dog();
          d.eat();  // inherited from Animal
          d.bark(); // Dog's own method
        
      

Polymorphism

Polymorphism means "many forms". In Java, the same method name can behave differently depending on the object or context. There are two types:

🎯 Exam Tips

Share:

Related Articles

YouTube