Thuta Learning
IntermediateProgrammingbeginner

OOP Intro

Relax. We'll talk through this in plain words — no textbook voice.

Object-Oriented Programming (OOP) is an approach that models a program after real-world objects. An object has data (attributes/fields) and behavior (methods). For example, a Student object can have data like name, age, and grade, along with behavior like study() and submitAssignment().

Java is a language built around OOP, with four core pillars.

Encapsulation — controlling data and providing safe access to it

Inheritance — a child class inheriting features from a parent class

Polymorphism — letting one method behave differently depending on the object

Abstraction — hiding unnecessary detail and showing only the important behavior

java
class Student {
  String name;

  void study() {
    System.out.println(name + " is studying Java.");
  }
}

public class Main {
  public static void main(String[] args) {
    Student student = new Student();
    student.name = "Aung";
    student.study();
  }
}

Student class is the blueprint. new Student() builds a Student object. The name field on the object gets set, and the study method gets called.

You should see
Aung is studying Java.

Real-World Use

App entities like User, Product, Order, Payment, Course, and Lesson are all built using classes and objects.

Easy traps

  • Beginners commonly mix up a class with an object, or try to call instance fields/methods without ever creating an object.
OOP Intro | Thuta Learning