This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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!