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 Main {5: x = new Comparable(Employee e); 6: System.out.print(x);7: }Chương trình trên sai

5/30

Cho class như sau:

1: public interface Comparable {

2: int compareTo(Employee other);

3: }

4: class Main {

5: x = new Comparable(Employee e);

6: System.out.print(x);

7: }

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

1

2, 4

5

8

Giải thích

Chọn đáp án C (Lỗi cú pháp. Không thể khởi tạo một interface, và biến x chưa được khai báo kiểu dữ liệu)