This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
tural ferhadov wrote:Why overriding method cannot have more restrictive access modifier.?
It can't because it will raise a compile error. It can however, declare a less restrictive access modifier. Here's the hierarchy of access modifier (1 being the most restrictive):
1 - private
2 - default
3 - protected
4 - public
If your superclass method is declared as default (no access modifier written), you can override it with the value of 2 - 4( just go down the hierarchy), but you can't go up to 1 (private) because you're making the method more restrictive.