public class A {
protected int x = 10;
}
public class B extends A {
public int read() { return x + 1; }
}
System.out.println(new B().read());What is printed?
- A
Compile-time error
- Bcheck_circle
11
- C
1
- D
10
Explanation
<code>protected</code> allows subclasses to access the field. read() returns 10 + 1.