| Author |
Round Up Game Question Contradiction?
|
Shannon Sims
Ranch Hand
Joined: Jul 03, 2003
Posts: 187
|
|
This Round Up game is fantastic! I truly love playing it. However I came across two questions that contradict each other??? Did I misinterpret the question/answer or are one of these answers incorrect? Question: Can a public method be overridden by a protected method? Answer: No, Overridding a method can NOT be more restrictive than the original method. Question: Can a method with no access modifier be overridden by a method marked protected? Answer: Yes, Overridden methods are allowed to have LESS restriction and since protected is less restricted than the default(package) that is allowed. Thank you,
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
"protected" is more restrictive than "public." "protected" is less restrictive than the default. Therefore, protected can override the default (opening up access) but it can't override public (closing off access.) OK? [ September 04, 2003: Message edited by: Ernest Friedman-Hill ]
|
[Jess in Action][AskingGoodQuestions]
|
 |
Anupam Sinha
Ranch Hand
Joined: Apr 13, 2003
Posts: 1088
|
|
Hi Ernest Ernest : The default is less restrictive than protected. I am sure you know, but just pointing out to correct it The default is more restrictive than protected.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
Aaaaah - sorry. I fixed my post. Now I see why the O.P. was confused!
|
 |
Shannon Sims
Ranch Hand
Joined: Jul 03, 2003
Posts: 187
|
|
OK, just so I totally understand, a method can be overridden as long as it's less restrictive than the method that is being overridden? Thanks!
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
|
Less, or equally, yes; just not more.
|
 |
Shannon Sims
Ranch Hand
Joined: Jul 03, 2003
Posts: 187
|
|
|
Thanks!!!
|
 |
 |
|
|
subject: Round Up Game Question Contradiction?
|
|
|