classVehicle { privateint speed; // Object Variable private String direction; // Object Variable, direction is a reference to String Object privatestaticintnumVehicle=0; // Class Variable publicVehicle() { // Constructor, called when new a Object this(0,"north"); // call another constructor to do initialization } publicVehicle(int s, String dir) { // Another Constructor. Use overloading to define two constructors float speed; // define a local variable speed = s; // the speed here refers to the above local variable this.speed = s; // If we want to set object variable, use this.speed to refer object variable speed direction = dir; // dir is a reference to object, not the object itself numVehicle++; // increase the Vehicle number } protectedvoidfinalize() { // Destructor, called when the object is garbage collected by JVM System.out.println("finalize has been called"); numVehicle--; } voidsetSpeed(int newSpeed) { // Object Method this.speed = newSpeed; } voidsetDir(String dir) { // Object Method this.direction = dir; } intgetSpeed() { // Object Method return speed; } String getDir() { // Object Method return direction; } publicstaticinttotalVehicle() { // Class Method return numVehicle; } }