TutorialsICSEClass 9Computer Science

Object Oriented Programming: Unleashed

Object Oriented Programming: easy ICSE Class 9 Computer Science notes with Java examples for students.

Updated
Tutorials

Object oriented programming is very important concept.

Watch Java videos

object oriented programming

https://www.youtube.com/watch?v=Rf6mkmhEW70

JAVA tutorials

What is object-oriented programming?

Object-oriented programming (OOP) organises a program around objects. Each object combines data, called data members or state, with the actions that work on that data, called methods or behaviour. Java, the language used for ICSE Computer Applications, is an object-oriented language.

Class and object

  • A class is a blueprint or template. It describes what data and methods its objects will have.
  • An object is an instance of a class: a real thing created from the blueprint, which occupies memory.
class Student {               // class = blueprint
    String name;              // data members (state)
    int marks;

    void display() {          // method (behaviour)
        System.out.println(name + " scored " + marks);
    }
}

// creating an object of the class
Student s1 = new Student();
s1.name = "Aarav";
s1.marks = 92;
s1.display();                 // Aarav scored 92

The four principles of OOP

  1. Encapsulation: wrapping data and methods into a single unit (the class) and hiding the data from outside access. Example: declaring data members private and providing methods to access them.
  2. Abstraction: showing only the essential features and hiding the details. Example: you call Math.sqrt(25) without knowing how the square root is calculated.
  3. Inheritance: one class acquires the properties of another class, which allows code to be reused. Example: class Car extends Vehicle.
  4. Polymorphism: one name with many forms. Example: method overloading, where area(int) and area(int, int) are different methods with the same name.

Why OOP matters for ICSE

Every Section B program in the ICSE Computer Applications paper is written as a class with data members and methods. A clear understanding of class, object and the four principles is also asked directly as 2-mark definitions in Section A.

Quick check: Which principle hides the implementation and shows only essential features? Abstraction. Which one binds data and methods together? Encapsulation.