Skip to content

Commit 360c958

Browse files
author
Ram swaroop
committed
merge pull request + minor bug fix
1 parent 8bba7fa commit 360c958

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

_posts/2015-05-22-access-control.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ package certification;
2828
public class Parent {
2929
protected int x = 9; // protected access
3030

31-
protected void printMessage(String message){
32-
System.out.println(message);
31+
protected int getX() {
32+
return x;
3333
}
3434
}
3535

@@ -43,8 +43,8 @@ class Child extends Parent {
4343
// p reference?
4444
System.out.println("X in parent is " + p.x); // Compiler
4545
// error
46-
System.out.println(p.printMessage("Calling Protected method of Parent class, Compiler should throw error."));//Compiler
47-
// error
46+
System.out.println("X in parent is " + p.getX()); // Compiler
47+
// error
4848
}
4949
}
5050
{% endhighlight %}

0 commit comments

Comments
 (0)