File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ranch Office and the fly likes Round Up Game Question Contradiction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "Round Up Game Question Contradiction?" Watch "Round Up Game Question Contradiction?" New topic
Author

Round Up Game Question Contradiction?

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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: 24183
    
  34

"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: 24183
    
  34

Aaaaah - sorry. I fixed my post.
Now I see why the O.P. was confused!
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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: 24183
    
  34

Less, or equally, yes; just not more.
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Round Up Game Question Contradiction?
 
Similar Threads
can an abstract method be overridden
Confusing question in the Rules roundup game of JavaRanch
method overriding
qs#333 of RRU
Can Any One Explain Me The Following Codes Briefly