259 câu trắc nghiệm tổng hợp Java cơ bản có đáp án

Đoạn mã sau có lỗi biên dịch gì? public class Person { protected String name; protected int age; public static void main(String[] args) { Person p = new Person(); p.name="Tom"; System.out.pri

34/259

Đoạn mã sau có lỗi biên dịch gì? public class Person { protected String name; protected int age; public static void main(String[] args) { Person p = new Person(); p.name="Tom"; System.out.println(p.name); } } Chọn một Câu trả lời 

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

name has protected access.

age has protected access.

name has public access.

Giải thích

Chọn đáp án A