Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusing question in the Rules roundup game of JavaRanch  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered the following question in the Rules Roundup.
(#333)TRUE or FALSE: an overriding method can change
the access modifier from default to protected.
Answer: TRUE
Since the protected modifier is less restrictive than
default, an overriding method is allowed to make that
change.

MY understanding that is when we override methods, we cannot make the overriding method more restricted.
Isn't Protected more restrictive than Default, which i assume is Friendly or Package.
-Hemanth

 
Sagar Sharma
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
friendly is more restrictive than protected because it dooes not allow access outside the package. Protedted features are allowed access outside the package provided that the overriding method is in a subclass of the base class..

Hope it helps
Sagar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!