259 câu trắc nghiệm tổng hợp Java cơ bản có đáp án

Đoạn mã sau có lỗi biên dịch nào? class Student { public int getAge(){ return 10; } } public class Man extends Student{ public double getAge() { return 11.2; } } Chọn một Câu trả lời

221/259

Đoạn mã sau có lỗi biên dịch nào?

class Student {

 public int getAge(){

 return 10;

 }

}

public class Man extends Student{

 public double getAge() {

 return 11.2;

 }

}

Chọn một Câu trả lời

Có lỗi biên dịch:getAge() in Man cannot override getAge() in Student return type int is not compatible with java.lang.int

Không có lỗi biên dịch.

Có lỗi biên dịch:getAge() in Man cannot override getAge() in Student because it is final

Có lỗi biên dịch:getAge() in Man and in Student has the same access modifier

Giải thích

Chọn đáp án A