Java / OOP Glossary

Reference · Canonical terms for this workspace

Core OOP

Class
A blueprint for creating objects. Defines fields (state) and methods (behavior).
Object
An instance of a class. Has identity, state, and behavior.
Encapsulation
Bundling data with methods that operate on it, restricting external access. Achieved via access modifiers. Protects invariants.
Avoid: "putting data inside a class"
Abstraction
Hiding implementation details behind a clean interface. Achieved via abstract classes and interfaces.
Avoid: "the same as encapsulation"
Inheritance
An IS-A relationship where a child class derives structure and behavior from a parent. Single-inheritance in Java (one parent per class).
Polymorphism
One interface, many implementations. Compile-time (overloading) and runtime (overriding via dynamic dispatch / vtable).
Compile-Time Polymorphism (Static / Early Binding)
Method resolved at compile time by signature. Achieved via method overloading. Faster, no runtime overhead.
Run-Time Polymorphism (Dynamic / Late Binding)
Method resolved at runtime based on actual object type. Achieved via method overriding. Uses vtable or equivalent dispatch mechanism.
Dynamic Method Dispatch
The mechanism by which the JVM selects the overridden method at runtime. The call goes to the actual object's class, not the reference type.
vtable (Virtual Table)
A dispatch table (array of function pointers) used by C++ to implement runtime polymorphism. Each class with virtual methods has one.
Abstract Class
A class that cannot be instantiated. Can have both abstract methods (no body) and concrete methods. Subclass must implement all abstract methods.
Abstract Method
A method declared without implementation. Must be overridden in a concrete subclass. Java: abstract void foo();. C++: virtual void foo() = 0;. Python: @abstractmethod.
Interface
A contract declaring method signatures. All methods are implicitly abstract (pre-Java 8). Java 8+ also allows default and static methods. C++ has no interface keyword; uses abstract classes with all pure virtual methods.
Default Method (Java 8+)
A method in an interface with a default implementation via the default keyword. Allows evolving interfaces without breaking existing implementations.
Static Method in Interface
A static method defined in an interface. Called on the interface name (InterfaceName.method()), not on instances. Cannot access instance variables.
static (Keyword)
Marks a member as belonging to the class, not an instance. Shared across all objects. Loaded once. Java/C++: static keyword. Python: class variables + @staticmethod.
Static Variable / Class Variable
A variable shared by all instances. Single copy in memory. Initialized when class is loaded. Java: static int x. C++: static int x + definition outside class. Python: x = 0 at class body level.
Static Method
Called on the class name, not an instance. No this/self reference. Cannot access instance members directly. Java/C++: static. Python: @staticmethod.
Static Block (Java)
Code block (static { ... }) executed once when the class is loaded. Used to initialize static variables. Runs before any constructor.
Static Local Variable (C++)
A local variable with static storage duration. Initialized once on first function call; value persists across calls. Thread-safe init since C++11.
Implements
Keyword indicating a class fulfills an interface contract. Java: class Foo implements Bar. C++: class Foo : public Bar. Python: class Foo(Bar).
Interface Inheritance
An interface extending another: interface Mammal extends Animal. The implementing class must fulfill all methods in the hierarchy.
Pure Virtual Function
C++ syntax for an abstract method: virtual void foo() = 0;. A class with at least one pure virtual function is abstract.
Composition
A HAS-A relationship where a class contains references to other objects. Prefer over inheritance for code reuse.
Association
A USES-A relationship. Weaker than composition; objects know about each other but don't own each other's lifecycle.
Attribute / Field / Property
Data member of a class. Represents the state of an object.
Method / Behavior
A function defined inside a class. Represents what an object can do.
Constructor
A special method called when an object is instantiated. Initializes state. Same name as class, no return type.
Getter / Setter
Methods that retrieve (get) or modify (set) private attributes. Enforce controlled access to encapsulated data.
this
Keyword referencing the current object instance. Used to disambiguate fields from constructor/method parameters.
Constructor Overloading
Multiple constructors in the same class with different parameter lists. Allows object creation with different initialization data.
Constructor Chaining
One constructor calling another to reuse initialization logic. Java: this(). C++: initializer list delegation. Python: super().__init__().
Copy Constructor
A constructor that creates a new object by copying an existing one. Built-in in C++; manual in Java and Python.
Data Hiding
The practice of restricting direct access to an object's internal state. A key goal of encapsulation.
Controlled Access
Providing public methods (getters/setters) while keeping attributes private, so all mutations can be validated.
Name Mangling
Python's attribute obfuscation: __var becomes _ClassName__var. Convention-based, not enforced — can still be accessed.
Superclass / Parent Class
The class being inherited from. Provides common members to subclasses.
Subclass / Child Class
A class that inherits from another class. Can reuse, extend, or override parent members.
extends
Java keyword for inheritance: class Child extends Parent.
Single Inheritance
One child inherits from one parent (one-to-one).
Multilevel Inheritance
A chain of inheritance: A → B → C. Each inherits from its immediate parent.
Hierarchical Inheritance
Multiple children inherit from a single parent (one-to-many).
Multiple Inheritance
A class inherits from more than one parent. Java disallows with classes (only interfaces). C++/Python allow it.
Diamond Problem
Ambiguity when a class inherits from two classes with the same method. Java avoids this by restricting multiple inheritance with classes.
Method Overriding
Subclass redefines a method inherited from its parent. Same signature. Enables runtime polymorphism.
super
Keyword to access parent class members or invoke parent constructor from a subclass.

Java Language

JVM (Java Virtual Machine)
Executes bytecode. Provides platform independence (WORA). Handles memory, garbage collection, JIT compilation.
Garbage Collection (GC)
Automatic memory management. Objects no longer referenced are reclaimed. No manual free().
Heap
Memory region where objects live. Managed by GC (Java/Python) or manually (C++).
Stack
Memory region for primitives and references/local variables. Auto-cleared at scope end. Fast, fixed-size per thread.
Reference
A variable that points to an object on the heap (Java/Python) or a pointer/reference (C++). Distinguished from the object itself.
Generics
Type parameters for classes/methods. List<String>. Implemented via type erasure (generic type info erased at runtime).
Autoboxing
Automatic conversion between primitives and their wrapper classes: int → Integer.
Type Erasure
Compiler removes generic type info, replacing with bounds or Object. Means List<String> is just List at runtime.
Checked Exception
Must be caught or declared (throws). IOException, SQLException.
Unchecked Exception
Runtime exception, not required to catch. NullPointerException, ArrayIndexOutOfBounds.
Marker Interface
An interface with no methods that signals a capability. Serializable, Cloneable.
Functional Interface
An interface with exactly one abstract method. Usable as lambda target. Runnable, Comparator.

Design Principles

SOLID
Five design principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
DRY (Don't Repeat Yourself)
Every piece of knowledge should have a single, unambiguous representation.
YAGNI (You Aren't Gonna Need It)
Don't add functionality until it's necessary.
Program to an Interface
Depend on abstractions, not concrete types. Enables substitution, testability, flexibility.
Favor Composition over Inheritance
Composition gives runtime flexibility and avoids the fragile base class problem. Use inheritance only for genuine IS-A with stable base.

Common Design Patterns

Singleton
Ensures a class has exactly one instance. Creational. Often overused; dependency injection is usually better.
Factory Method
Defines an interface for creating objects, subclasses decide which class to instantiate. Creational.
Strategy
Defines a family of algorithms, encapsulates each, makes them interchangeable. Behavioral. The canonical "favor composition" pattern.
Observer
Defines a one-to-many dependency so that when one object changes state, all dependents are notified. Behavioral.
Decorator
Attaches additional responsibilities to an object dynamically. Structural. Wraps the original object.
Adapter
Converts one interface to another a client expects. Structural. "Wrapper."