khoahoc.vietjack.com

Câu hỏi:

11/06/2026 2 Lưu

Đ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 int getAge(int added) {

return super.getAge()+added;

}

}

A.

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

B.

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

C.

Có lỗi biên dịch:call to super, must be the first in constructor in class Man.

D.

Có lỗi biên dịch: getAge() in Student and Man can not have the same access arguments.

Quảng cáo

Trả lời:

verified Giải bởi Vietjack

Chọn đáp án A

Vì:

getAge() ở Student và Man có arguments khác nhau, nên chúng là các phương thức khác nhau.