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

Query on Overriding  RSS feed

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a method is overrided there is a restriction that the method in the sub class cannot be more restrictive than the original.

public void print() {} cannot be overrided to
protected void print() {}

But what about the default access specifier i.e "void print() {}" ?
 
Jimmy Die
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Default is more restrictive then protected and less then private.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the it's like this

private --> default ---> protected --> public
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume the arrow (-->) means "is more restrictive than". If so, then you are correct.

Layne
[ February 24, 2005: Message edited by: Layne Lund ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!