• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

overriding

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 129)
public interface AQuestion
{
void someMethod();
}
The class which implements AQuestion
Should have someMethod which must necessarily be coderanch.
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.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Methods declared in an interface are inherently coderanch, 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic