Back to Lessons

Classes and Objects Fundamentals

April 5, 2026

Classes and Objects

Fundamental OOP concepts defining blueprint and instances.

Class Example

public class Car {
    String brand;
    int year;
    
    public Car(String brand, int year) {
        this.brand = brand;
        this.year = year;
    }
    
    public void start() {
        System.out.println(brand + " started");
    }
}

Key Points

  • Class = blueprint, Object = instance.
  • this refers to current object.
  • Constructor has same name as class.
  • Usage: Car myCar = new Car("Toyota", 2023);.