从 W3Schools.cn 在线教程学习 Web 网络开发
运行结果尺寸: 625 x 591
Car.java
 


class Vehicle {
  protected String brand = "Ford";
  public void honk() {
    System.out.println("Tuut, tuut!");
  }
}

class Car extends Vehicle {
  private String modelName = "Mustang";
  public static void main(String[] args) {
    Car myFastCar = new Car();
    myFastCar.honk();
    System.out.println(myFastCar.brand + " " + myFastCar.modelName);
  }
}


Result:
Tuut, tuut!
Ford Mustang