This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

qs#333 of RRU

 
Nalini Mistry
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the answer says that a default method can be overridden with a protected method coz less restrictive is allowed. From what i have studied, more restrictive is allowed, less restrictive isnt. Please clarify.
 
paul wheaton
Trailboss
Pie
Posts: 21749
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case, the game is correct. Less restrictive is allowed.
Think of polymorphism. If you made it more restrictive, would stuff that is not directly aware of the more restrictive method be allowed to have access? Nope. Therefore, you have a breakdown of polymorphism. If you allow less restriction, polymorphism still works!
One way to be sure -- warm up that compiler and try it out!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic