Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

qs#333 of RRU

 
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.
 
Trailboss
Posts: 23194
IntelliJ IDE Firefox Browser 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!
 
    Bookmark Topic Watch Topic
  • New Topic