Challenge 3 Java

Đoạn code dưới đây sẽ in ra dòng chữ gì? hãy chọn 1 đáp án

package vehicles;

class Automobile {
    private final String drive() {
        return "Driving vehicle";
    }
}

class Car extends Automobile {
    protected String drive() {
        return "Driving car";
    }
}

public class ElectricCar extends Car {
    public final String drive() {
        return "Driving electric car";
    }
    public static void main(String[] wheels) {
        final Car car = new ElectricCar();
        System.out.print(car.drive());
    }
}

A. Driving vehicle
B. Driving electric car
C. Driving car
D. The code does not compile.

Bạn hãy comment câu trả lời của bạn và so sánh với solution ở page 2.

0 0 votes
Đánh giá challenge
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Thu An
Thu An
2 years ago

Hi bạn, mình đang thắc mắc một chỗ: Mình không thấy annotation “@Override” ở trước [dòng 16] thì sao có thể override được nhỉ?