aspose file tools
The moose likes Ranch Office and the fly likes Round Up Game Question Contradiction? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » This Site » Ranch Office
Reply 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: 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
    
  15

"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
    
  15

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
    
  15

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

Joined: Jul 03, 2003
Posts: 187
Thanks!!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Round Up Game Question Contradiction?
 
Similar Threads
qs#333 of RRU
can an abstract method be overridden
Can Any One Explain Me The Following Codes Briefly
Confusing question in the Rules roundup game of JavaRanch
method overriding