Java Oop 2
Java Oop 2
return 0;
this.length = length;
this.width = width; }
QSTN 2
class Vehicle {
System.out.println("Drive a car");
class Car extends Vehicle {
System.out.println("Repairing a car");
vehicle.drive();
car.drive();
QSTN 3
class Vehicle {
this.make = make;
this.model = model;
this.year = year;
this.fuelType = fuelType;
return 0;
public Truck(String make, String model, int year, String fuelType, int cargoCapacity) {
this.cargoCapacity = cargoCapacity;
return 120; }
public Car(String make, String model, int year, String fuelType, int numberOfSeats) {
this.numberOfSeats = numberOfSeats;
return 180; }
}
class Motorcycle extends Vehicle {
public Motorcycle(String make, String model, int year, String fuelType, boolean hasSideCar) {
this.hasSideCar = hasSideCar;
return 200;
}
QSTN 4
class Shape {
return 0.0;
}
public double getArea() {
return 0.0;
this.radius = radius;