aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes declarations and modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "declarations and modifiers" Watch "declarations and modifiers" New topic
Author

declarations and modifiers

k duffy
Greenhorn

Joined: Aug 29, 2004
Posts: 11
Sun Objective 1.2

the following question is from Sun Certified Programmer & Developer for Java 2
by Sierra & Bates

Which of the following are legal declarations for nonnested classes and interfaces? (Choose two)
a. final abstract class Test{}
b. public static interface Test{}
c. final public class Test{}
d. protected abstract class Test{}
e. protected interface Test{}
f. abstract public class Test{}


lets see
a. final and abstract are opposites so wrong
b. interface can not be declared static
c. OK
d. protected can only be used on members
e. protected can only be used on members
f. OK

Book says C & F
but look at C the question said for interfaces, an
interface can not be final.

confused.

thanks in advance for your help.

kd
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
kd,

The question is as follows.

Which of the following are legal declarations for nonnested classes and interfaces?

Answer option C is as follows.

c. final public class Test{}

The modifiers final and public can legally be applied to a class declaration, so I don't see any problem with it.
[ August 29, 2004: Message edited by: Dan Chisholm ]

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

the correct answers are C & F..
here declared all are classes not interfaces.


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
k duffy
Greenhorn

Joined: Aug 29, 2004
Posts: 11
ok yes, now I understand.
The mention of interfaces in the question threw me off.
I wonder why that was tossed in there.

Thanks for your kind feedback.

kd
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: declarations and modifiers