• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

declarations and modifiers

 
k duffy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the correct answers are C & F..
here declared all are classes not interfaces.
 
k duffy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic