class Student { public int getAge() { return 10; } } public class Man extends Student { protected int getAge(int added) { return super.getAge()

Nguyên Kim

New member
class Student {
public int getAge() {
return 10;
}
}
public class Man extends Student {
protected int getAge(int added) {
return super.getAge() + added;
}
}</blockquote>
Đoạn mã sau có lỗi biên dịch nào?
A. Không có lỗi biên dịch.
B. Có lỗi biên dịch: getAge() has in Man can not have weaker same access modifier than in Student.
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.
 

Phạm Duy

New member
Hướng dẫn
Chọn A là đáp án đúng
Xem lời giải
Xem lời giải
Không có lỗi biên dịch.
Vì:
getAge() ở Student và Man có arguments khác nhau, nên chúng là các phương thức khác nhau.