Created
April 4, 2012 14:26
-
-
Save sourcerebels/2301727 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Father.java | |
package test; | |
public class Father { | |
protected void hello() { | |
System.out.println("hello"); | |
} | |
} | |
//Son.java | |
package test; | |
public class Son extends Father { | |
public void tellYourFatherSayHello() { | |
hello(); | |
} | |
} | |
//StrangerSamePackage.java | |
package test; | |
public class StrangerSamePackage { | |
public void sayHello() { | |
Father f = new Father(); | |
f.hello(); | |
} | |
} | |
//SonOtherPackage.java | |
package other; | |
public class SonOtherPackage extends Father { | |
public void tellYourFatherSayHello() { | |
hello(); | |
} | |
} | |
//StrangerOtherPackage.java | |
package other; | |
public class StrangerOtherPackage { | |
public void sayHello() { | |
Father f = new Father(); | |
f.hello(); // COMPILATION ERROR | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment