Services Work Learn About Contact
0/10
Lesson 7 of 10

Classes & Objects

A class is a blueprint for creating objects. It defines properties (fields) and behaviors (methods). An object is an instance of a class. Use the new keyword to create objects.

JAVA
public class Car {
  String brand;
  int year;

  void drive() {
    System.out.println("Driving " + brand);
  }

  public static void main(String[] args) {
    Car myCar = new Car();
    myCar.brand = "Toyota";
    myCar.year = 2023;
    myCar.drive();
  }
}
🧠

Quick Quiz

Answer correctly to unlock the next lesson.

Support the mission

This learning platform is 100% free: no ads, no tracking, no paywalls. If it helped you learn something useful, you can support future lessons or donate to Doctors Without Borders, which provides emergency medical care in crisis zones worldwide.

🎉

You completed Java!

You finished all 10 lessons and quizzes. You now know the basics of Java.