We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8bba7fa commit 360c958Copy full SHA for 360c958
1 file changed
_posts/2015-05-22-access-control.md
@@ -28,8 +28,8 @@ package certification;
28
public class Parent {
29
protected int x = 9; // protected access
30
31
- protected void printMessage(String message){
32
- System.out.println(message);
+ protected int getX() {
+ return x;
33
}
34
35
@@ -43,8 +43,8 @@ class Child extends Parent {
43
// p reference?
44
System.out.println("X in parent is " + p.x); // Compiler
45
// error
46
- System.out.println(p.printMessage("Calling Protected method of Parent class, Compiler should throw error."));//Compiler
47
- // error
+ System.out.println("X in parent is " + p.getX()); // Compiler
+ // error
48
49
50
{% endhighlight %}
0 commit comments