Đ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;
}
}
Không có lỗi biên dịch.
Có lỗi biên dịch: getAge() in Student and Man can not have the same access modifier.
Có lỗi biên dịch:call to super, must be the first in constructor in class Man.
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:
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.
Hot: 1000+ Đề thi cuối kì 2 file word cấu trúc mới 2026 Toán, Văn, Anh... lớp 1-12 (chỉ từ 60k). Tải ngay