Created
July 29, 2011 05:16
-
-
Save browny/1113176 to your computer and use it in GitHub Desktop.
[Java] Access modifier of an overriding method
This file contains 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
class Base { | |
private int privMethod() { return 1; } | |
int packMethod() { return 1; } | |
protected int protMethod() { return 1; } | |
public int pubMethod() { return 1; } | |
} | |
class Derived extends Base { | |
//@Override | |
//private int pubMethod() { return 0; } // Error | |
//int pubMethod() { return 0; } // Error | |
//protected int pubMethod() { return 0; } // Error | |
//public int pubMethod() { return 0; } // OK | |
//@Override | |
//private int protMethod() { return 0; } // Error | |
//int protMethod() { return 0; } // Error | |
//protected int protMethod() { return 0; } // OK | |
//public int protMethod() { return 0; } // OK | |
//@Override | |
//private int packMethod() { return 0; } // Error | |
//int packMethod() { return 0; } // OK | |
//protected int packMethod() { return 0; } // OK | |
//public int packMethod() { return 0; } // OK | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment