MulaiMulai sekarang secara gratis

Add properties to car class

You will add more features to the Car class and a few properties that mimic a real car. A real car has endless features, but for now, you will only add the car's color, model, and year of manufacture.

Latihan ini adalah bagian dari kursus

Introduction to Object-Oriented Programming in Java

Lihat Kursus

Petunjuk latihan

  • Add a string property color to the Car class for the color of a car.
  • Add a string property model to the Car class for the model of a car.
  • Add an integer property year to the Car class to the year a car was made.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

class Main {  

  static class Car {
      // Create the properties for the class
      ____ ____;
      ____ ____;
      ____ ____;
  }
  
  public static void main(String[] args) {

  }
}
Edit dan Jalankan Kode