OOP Terminology Reference

IB Syllabus: B3.1, B3.2 – Every OOP term you need for Paper 2, with mark-scheme-quality definitions and code examples.

Table of Contents

  1. Why This Page Exists
  2. Classes and Objects (B3.1)
    1. Class
    2. Object
    3. Instantiation
    4. Constructor
    5. Dot Notation
  3. Encapsulation and Information Hiding (B3.1.5)
    1. Encapsulation
    2. Information Hiding
    3. Access Modifiers
    4. Accessor (Getter) Method
    5. Mutator (Setter) Method
  4. The this Keyword (B3.1)
    1. this
  5. Static vs Instance Members (B3.1.3)
    1. Instance Variable
    2. Static Variable (Class Variable)
    3. Instance Method
    4. Static Method
  6. Object References (B3.1)
    1. Reference
    2. Aliasing
    3. null
    4. == vs .equals()
  7. UML Class Diagrams (B3.1.2)
    1. UML Class Diagram
  8. Aggregation (B3.1)
    1. Aggregation
    2. Delegation
  9. Inheritance (B3.2.1) – HL
    1. Inheritance
    2. extends
    3. super
    4. Constructor Chaining
  10. Polymorphism (B3.2.2) – HL
    1. Polymorphism
    2. Method Overriding
    3. @Override Annotation
    4. Dynamic Dispatch (Runtime Polymorphism)
    5. Overriding vs Overloading
  11. Abstraction (B3.2.3) – HL
    1. Abstract Class
    2. Abstract Method
    3. Interface
  12. Composition and Aggregation (B3.2.4) – HL
    1. Composition
    2. Aggregation (Revisited – HL Context)
    3. Composition vs Aggregation vs Inheritance
  13. Design Patterns (B3.2.5) – HL
    1. Singleton Pattern
    2. Factory Pattern
    3. Observer Pattern
  14. Quick Reference Table
  15. Quick Check
  16. Code Completion
  17. Spot the Error
  18. Predict the Output
  19. Practice Exercises
    1. Core
    2. Extension
    3. Challenge
  20. Connections

Why This Page Exists

IB Paper 2 regularly asks students to define, distinguish, or explain OOP concepts. Many marks are lost not because students lack understanding, but because they use imprecise language. This page collects every OOP term from B3.1 and B3.2 with definitions written the way IB mark schemes expect them.

Use this page for revision. Each term includes:

  • A mark-scheme definition (the wording examiners look for)
  • A code snippet showing the term in action
  • Exam tips where relevant

Classes and Objects (B3.1)

Class

A template/blueprint that defines the attributes (data) and methods (behaviour) that its objects will have. A class does not hold data itself – it describes the structure that objects will follow.

public class Dog {
    private String name;
    private int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() { return name; }
    public void bark() { System.out.println(name + " says Woof!"); }
}

Mark-scheme phrasing: “A class is a blueprint/template that defines the attributes and methods common to all objects of that type.”

Object

A specific instance of a class, created at runtime. Each object has its own copy of the instance variables defined by the class.

Dog rex = new Dog("Rex", 5);
Dog bella = new Dog("Bella", 3);
// rex and bella are two separate objects of the Dog class

Mark-scheme phrasing: “An object is an instance of a class, created using the new keyword, with its own set of attribute values.”

Instantiation

The process of creating an object from a class using the new keyword. This allocates memory for the object and calls its constructor.

Dog rex = new Dog("Rex", 5);  // instantiation

Constructor

A special method that is called automatically when an object is created with new. It initialises the object’s attributes to valid starting values.

public Dog(String name, int age) {   // constructor -- same name as class, no return type
    this.name = name;
    this.age = age;
}

Key facts:

  • Same name as the class
  • No return type (not even void)
  • Called automatically by new
  • Can be overloaded (multiple constructors with different parameter lists)

Dot Notation

The syntax used to access an object’s methods and (if visible) attributes: object.method() or object.attribute.

rex.bark();              // call a method
String n = rex.getName(); // call a getter

Encapsulation and Information Hiding (B3.1.5)

Encapsulation

Bundling an object’s data (attributes) and the methods that operate on that data into a single unit (a class), while restricting direct access to the data from outside.

Mark-scheme phrasing: “Encapsulation is the bundling of data and methods into one unit and restricting direct access to internal data by making attributes private and providing public methods to access or modify them.”

Information Hiding

Making the internal state of an object invisible to outside code. External code can only interact with the object through its public methods, not by accessing fields directly. This protects data integrity.

In practice, information hiding is achieved through private fields and public getter/setter methods.

Access Modifiers

Keywords that control which parts of a program can access a class member.

Modifier Same Class Same Package Subclass Everywhere
private Yes No No No
default (no keyword) Yes Yes No No
protected Yes Yes Yes No
public Yes Yes Yes Yes

Exam rule of thumb: attributes are private, methods are public, helper methods are private.

Accessor (Getter) Method

A public method that returns the value of a private attribute without modifying it.

public String getName() {
    return name;
}

Mutator (Setter) Method

A public method that modifies the value of a private attribute, often including validation.

public void setAge(int age) {
    if (age >= 0) {
        this.age = age;
    }
}

Why validation matters in setters: Without validation, external code could set invalid values (e.g., negative age). Setters act as gatekeepers.


The this Keyword (B3.1)

this

A reference to the current object – the object whose method or constructor is currently executing. Most commonly used to resolve parameter shadowing, where a constructor/method parameter has the same name as an instance variable.

public Dog(String name, int age) {
    this.name = name;   // this.name = instance variable, name = parameter
    this.age = age;
}

Static vs Instance Members (B3.1.3)

Instance Variable

A variable that belongs to each individual object. Every object has its own copy.

private String name;  // each Dog has its own name

Static Variable (Class Variable)

A variable shared by all objects of the class. Only one copy exists, regardless of how many objects are created.

private static int dogCount = 0;  // shared across all Dog objects

Instance Method

A method that operates on a specific object’s data. It can access both instance and static variables.

public String getName() { return name; }  // acts on this object's name

Static Method

A method that belongs to the class itself, not to any individual object. It cannot access instance variables or use this.

public static int getDogCount() {
    return dogCount;  // can only access static variables
}

Mark-scheme phrasing: “A static method belongs to the class, not to an instance. It can be called without creating an object and cannot access instance variables.”

Common exam mistake: Writing this.dogCount inside a static method. Static methods have no this – they do not belong to any object.


Object References (B3.1)

Reference

A variable that stores the memory address of an object, not the object itself. When you assign one object variable to another, you copy the reference, not the object.

Dog a = new Dog("Rex", 5);
Dog b = a;     // b points to the SAME object as a
b.bark();      // "Rex says Woof!" -- same object

Aliasing

When two or more variables refer to the same object in memory. Changes through one variable are visible through the other.

Dog a = new Dog("Rex", 5);
Dog b = a;  // aliasing -- a and b point to the same Dog

null

A special value meaning “no object”. A reference variable that has not been assigned an object holds null. Calling a method on null throws a NullPointerException.

Dog c = null;
c.bark();      // NullPointerException at runtime

== vs .equals()

== compares references (whether two variables point to the same object). .equals() compares content (whether two objects are meaningfully equivalent).

String s1 = new String("hello");
String s2 = new String("hello");
System.out.println(s1 == s2);      // false -- different objects
System.out.println(s1.equals(s2)); // true -- same content

Exam rule: Always use .equals() to compare Strings in Java. Using == compares references, which is almost never what you want.


UML Class Diagrams (B3.1.2)

UML Class Diagram

A standardised visual representation of a class showing three sections:

┌──────────────────────┐
│      ClassName        │  ← class name
├──────────────────────┤
│ - name: String        │  ← attributes (with visibility)
│ - age: int            │
├──────────────────────┤
│ + getName(): String   │  ← methods (with visibility)
│ + setAge(int): void   │
└──────────────────────┘

Visibility symbols:

  • - = private
  • + = public
  • # = protected

Mark-scheme phrasing: “A UML class diagram represents a class with three compartments: class name, attributes (with types and visibility), and methods (with parameters, return types, and visibility).”


Aggregation (B3.1)

Aggregation

A “has-a” relationship where one object contains a reference to another object, but the contained object can exist independently. If the container is destroyed, the contained object still exists.

public class Kennel {
    private Dog[] dogs;   // Kennel HAS dogs, but dogs exist without the kennel
}

Delegation

When an object passes responsibility for a task to one of its contained objects by calling that object’s method.

public String getDogName(int index) {
    return dogs[index].getName();  // delegates to Dog's getName()
}

Inheritance (B3.2.1) – HL

The following terms are HL only.

Inheritance

A mechanism where a child class (subclass) automatically receives all non-private attributes and methods from a parent class (superclass), and can add new ones or override existing ones. This promotes code reuse and models an “is-a” relationship.

public class Puppy extends Dog {
    private boolean trained;

    public Puppy(String name, int age, boolean trained) {
        super(name, age);        // call parent constructor
        this.trained = trained;
    }
}

Mark-scheme phrasing: “Inheritance allows a subclass to reuse (inherit) the attributes and methods of a superclass, promoting code reusability and establishing an is-a relationship.”

extends

The Java keyword that declares inheritance. class Child extends Parent means Child inherits from Parent.

super

A reference to the parent class. Used to:

  1. Call the parent constructor: super(args)
  2. Call a parent method that has been overridden: super.methodName()

Constructor Chaining

When a child constructor calls the parent constructor using super() to initialise inherited attributes before initialising its own.

public Puppy(String name, int age, boolean trained) {
    super(name, age);        // parent constructor runs first
    this.trained = trained;  // then child-specific initialisation
}

Polymorphism (B3.2.2) – HL

Polymorphism

The ability of a parent-type variable to hold objects of different child types, with method calls dispatching to the correct child version at runtime.

Dog[] dogs = new Dog[2];
dogs[0] = new Dog("Rex", 5);
dogs[1] = new Puppy("Spot", 1, false);  // Puppy IS-A Dog

Mark-scheme phrasing: “Polymorphism allows objects of different subclasses to be treated as objects of a common superclass, with method calls resolved at runtime to the appropriate subclass version.”

Method Overriding

When a child class provides its own implementation of a method inherited from the parent. The child version replaces the parent version for objects of the child type.

public class Puppy extends Dog {
    @Override
    public void bark() {
        System.out.println(getName() + " says Yap!");  // replaces parent's bark()
    }
}

@Override Annotation

A marker placed before a method to tell the compiler “I intend to override a parent method.” If the method signature does not match any parent method, the compiler produces an error – catching typos early.

Dynamic Dispatch (Runtime Polymorphism)

The process by which Java determines at runtime (not compile time) which version of an overridden method to execute, based on the actual object type, not the variable type.

Dog d = new Puppy("Spot", 1, false);
d.bark();  // calls Puppy's bark(), not Dog's -- decided at runtime

Overriding vs Overloading

  Overriding Overloading
Where Child class Same class
Method name Same Same
Parameters Same Different
Decided Runtime Compile time
Keyword @Override None required

Abstraction (B3.2.3) – HL

Abstract Class

A class declared with the abstract keyword that cannot be instantiated. It serves as a base class that defines common structure and may contain abstract methods that subclasses must implement.

public abstract class Animal {
    private String name;

    public Animal(String name) { this.name = name; }
    public String getName() { return name; }

    public abstract void makeSound();  // no body -- subclasses must provide one
}

Abstract Method

A method declared without a body (no {}). Any concrete (non-abstract) subclass must override it, providing an implementation.

public abstract void makeSound();  // declaration only -- no body

Mark-scheme phrasing: “An abstract class cannot be instantiated and may contain abstract methods – methods with no implementation that must be overridden by any concrete subclass.”

Interface

A contract that specifies methods a class must implement, without providing any implementation itself. A class can implement multiple interfaces (unlike single inheritance).

public interface Trainable {
    void train();             // all methods are implicitly public and abstract
    boolean isTrained();
}

public class Puppy extends Dog implements Trainable {
    public void train() { /* implementation */ }
    public boolean isTrained() { return trained; }
}

Interface vs Abstract Class:

  Interface Abstract Class
Instantiate? No No
Multiple? A class can implement many A class can extend only one
Methods All abstract (no bodies) Mix of abstract and concrete
Fields Constants only (static final) Instance variables allowed
When to use Define a capability (“can do”) Define a shared base (“is a kind of”)

Composition and Aggregation (B3.2.4) – HL

Composition

A strong “has-a” relationship where the contained object’s lifecycle is tied to the container. When the container is destroyed, the contained objects are destroyed too.

public class House {
    private Room[] rooms;

    public House(int numRooms) {
        rooms = new Room[numRooms];
        for (int i = 0; i < numRooms; i++) {
            rooms[i] = new Room();  // rooms are created WITH the house
        }
    }
    // if the House is destroyed, the Rooms go with it
}

Aggregation (Revisited – HL Context)

A weak “has-a” relationship where the contained object exists independently of the container. The container holds a reference, but does not control the contained object’s lifecycle.

public class Kennel {
    private Dog resident;

    public Kennel(Dog dog) {
        this.resident = dog;  // dog was created outside -- exists independently
    }
}

Mark-scheme phrasing (composition vs aggregation): “In composition, the contained object cannot exist without the container (lifecycle dependency). In aggregation, the contained object can exist independently.”

Composition vs Aggregation vs Inheritance

Relationship Type Example Coupling
Inheritance “is-a” Puppy is a Dog Tight
Composition “has-a” (strong) House has Rooms Medium
Aggregation “has-a” (weak) Kennel has a Dog Loose

Design principle: Favour composition over inheritance when possible. Composition gives flexibility without tight coupling.


Design Patterns (B3.2.5) – HL

Singleton Pattern

Ensures a class has only one instance and provides a global point of access to it. Useful for shared resources (e.g., a database connection, a settings manager).

Factory Pattern

Uses a method to create objects without exposing the creation logic to the caller. The caller specifies what type of object it wants, and the factory returns the appropriate subclass instance.

Observer Pattern

Defines a one-to-many dependency: when one object (the subject) changes state, all its dependents (observers) are notified and updated automatically. Useful for event-driven systems.

You are not expected to write full implementations of these patterns in the exam, but you should be able to explain what each one does and when it is useful.


Quick Reference Table

Term One-Line Definition Section
Class Blueprint defining attributes and methods B3.1
Object Instance of a class with its own data B3.1
Instantiation Creating an object using new B3.1
Constructor Method that initialises a new object B3.1
Encapsulation Bundling data + methods, restricting access B3.1.5
Information Hiding Making internal state invisible to outside code B3.1.5
Access Modifier Keyword controlling member visibility B3.1.5
Getter / Setter Methods to read / write private attributes B3.1.5
this Reference to the current object B3.1
Static variable Shared by all objects of a class B3.1.3
Static method Belongs to the class, not an instance B3.1.3
Reference Memory address pointing to an object B3.1
Aliasing Two variables pointing to the same object B3.1
null Special value meaning “no object” B3.1
UML class diagram Three-section visual representation of a class B3.1.2
Aggregation Weak has-a (independent lifecycle) B3.1 / B3.2.4
Delegation Passing a task to a contained object’s method B3.1
Inheritance Subclass reuses superclass members (is-a) B3.2.1 HL
Polymorphism Parent variable holds child objects; runtime dispatch B3.2.2 HL
Method Overriding Child replaces parent method (same signature) B3.2.2 HL
Dynamic Dispatch Runtime selection of overridden method B3.2.2 HL
Abstract Class Cannot be instantiated; may have abstract methods B3.2.3 HL
Interface Contract of methods a class must implement B3.2.3 HL
Composition Strong has-a (lifecycle dependency) B3.2.4 HL

Quick Check

Q1. Which term describes "bundling data and methods into one unit while restricting direct access to internal data"?

Q2. Why can a static method NOT access instance variables?

Q3. Given String s1 = new String("hi"); and String s2 = new String("hi");, what does s1 == s2 return?

Q4. What is the key difference between composition and aggregation?

Q5. A child class defines a method with the same name and parameters as a parent method, replacing its behaviour. This is called:


Code Completion

Complete the missing terms in these definitions.

Fill in the blanks: Complete each OOP definition with the correct term.

// 1. A __________ is a blueprint that defines attributes and methods.
//    Objects are instances of a .

// 2. Making attributes private and providing public getters/setters
//    is an example of .

// 3. When two variables point to the same object in memory,
//    this is called .

// 4. A variable declared as static is shared by all
//     of the class.

// 5. The process of creating an object using new is
//    called .

Spot the Error

A student wrote this definition on a test. Find the line with the incorrect claim.

Bug Hunt: One of these comments contains an incorrect claim about OOP. Find it.

1// A class is a blueprint that defines attributes and methods 2// An object is an instance of a class created using new 3// Encapsulation bundles data and methods, restricting access 4// A static method can access both static and instance variables 5// Aggregation models a has-a relationship between objects

Pick the correct fix for line 4:


Predict the Output

Predict: What does this code print? (This tests your understanding of polymorphism and dynamic dispatch.)

public class Dog {
    public void speak() { System.out.println("Woof!"); }
}

public class Puppy extends Dog {
    @Override
    public void speak() { System.out.println("Yap!"); }
}

// In main:
Dog d = new Puppy();
d.speak();

Predict: What does this code print? (This tests your understanding of references and aliasing.)

Dog a = new Dog("Rex", 5);
Dog b = a;
a = new Dog("Bella", 3);
System.out.println(b.getName());

Practice Exercises

Core

  1. Define five terms – Without looking at this page, write mark-scheme-quality definitions for: class, object, encapsulation, constructor, and access modifier. Then compare with the definitions above.

  2. UML from code – Draw a UML class diagram for the Dog class shown on this page, including all attributes, the constructor, and all methods with correct visibility symbols.

  3. Static vs Instance – Explain, with an example, why a getDogCount() method should be static but a getName() method should not be.

Extension

  1. Relationship identification – For each pair, state whether the relationship is inheritance, composition, or aggregation, and justify your answer:
    • Car and Engine
    • Student and Person
    • Library and Book
    • ArrayList and Object
  2. Compare and contrast – Write a paragraph comparing method overriding and method overloading. Include: where each occurs, how parameters differ, and when Java decides which method to call.

Challenge

  1. Design pattern scenario – A school management system needs to ensure there is only ever one SchoolDatabase object. Which design pattern is appropriate? Explain how it works and why creating multiple database connections would be problematic.

Connections


© EduCS.me — A resource hub for IB Computer Science

This site uses Just the Docs, a documentation theme for Jekyll.