EMZETT.
Login

OOP

In short: Object-oriented programming — the central paradigm of Java, where programs consist of objects with state (fields) and behaviour (methods) instead of pure sequences of functions.

In more detail: Java enforces OOP more strictly than many other languages: every method has to sit within a class, there are no “free” functions. The four core pillars are encapsulation (Encapsulation), inheritance (Inheritance), polymorphism (Polymorphism), and abstraction (Abstraction).

In Depth

// Encapsulation: state protected, controlled access
class Account {
    private double balance;
    public double getBalance() { return balance; }
}
 
// Inheritance: reuse base behaviour
class SavingsAccount extends Account {
    double interestRate;
}
 
// Polymorphism: same method, different behaviour depending on actual type
class Animal { void makeSound() { System.out.println("..."); } }
class Cat extends Animal { void makeSound() { System.out.println("Meow"); } }
Animal a = new Cat();
a.makeSound(); // "Meow" - the overridden version runs
 
// Abstraction: contract with no concrete implementation
interface PaymentMethod { void pay(double amount); }

These four core pillars work together, not in isolation: inheritance and polymorphism, for example, enable a list of type List<Animal> that can hold any concrete animal species, while every call to .makeSound() automatically uses the correct, overridden version depending on the actual object type — calling code doesn’t even need to know the concrete subclass. Java enforces the OOP paradigm more strictly than, say, JavaScript or Python: even a simple main method has to sit within a class, there are no genuinely free-standing, classless functions. Other programming languages implement quite different paradigms in some cases (functional: Haskell, procedural: classic C) — the language-independent basic concept “object orientation” itself is described in OOP (general).

See also: Classes, Objects, Encapsulation, Inheritance, Polymorphism, Abstraction