200+ câu trắc nghiệm Lập trình Java cơ sở có đáp án - Phần 7

Cho class như sau:java1: public interface Comparable { 2: int compareTo(Employee other);3: }4: class Employee implements Comparable { // Giả định sửa lỗi cú pháp ở đây5: public int compareTo(

3/30

Cho class như sau:

1: public interface Comparable {

2: int compareTo(Employee other);

3: }

4: class Employee implements Comparable { // Giả định sửa lỗi cú pháp ở đây

5: public int compareTo(Employee other) {

6: return 0;

7: }

8: }

Chương trình trên sai ở dòng nào?

1

2, 4

5

Không sai ở dòng nào cả

Giải thích

Chọn đáp án D (Với giả định sửa implements Comparable thành implements Comparable)