File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assigning weaker privileges

 
Pratik D mehta
Ranch Hand
Posts: 121
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What are the possible reasons that we cant assign weaker privileges to overridden methods in subclass ?
 
Bobby Smallman
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Subclasses must be usable as instances of their super. Reducing visibility would violate this contract.

https://www.securecoding.cert.org/confluence/display/java/SCP01-J.+Do+not+increase+the+accessibility+of+overridden+or+hidden+methods
 
Pratik D mehta
Ranch Hand
Posts: 121
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you I got the visibility modifiers stuff .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic