This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "overriding" Watch "overriding" New topic
Author

overriding

wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
Question 129)
public interface AQuestion
{
void someMethod();
}
The class which implements AQuestion
Should have someMethod which must necessarily be public.
Should have someMethod which could be "friendly" or public
Should have someMethod which should not throw any checked exceptions.
Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface defination
---------------
the ans are 1st and 3rd. why is 1st choice right? i thought 2nd was correct. friendly to friendly for overriding should be fine.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Methods declared in an interface are inherently public, even if you don't include the keyword. Therefore the implemented method must be public in any class. In any event, answers 1 and 2 are mutually exclusive, so its either/or.
The synchronized keyword is not inheritable. Any method can be synchronized regardless of the method it is overriding.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: overriding