aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface question" Watch "Interface question" New topic
Author

Interface question

Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Source http://www.wbrogden.com/
Which of the following statements about interfaces is correct?
A Due to Java's principle of single inheritance, a class declaration can only name one interface.
B All methods in an interface have default accessibility unless declared otherwise.
C All methods in an interface have public accessibility.
D An interface may not contain any variables.

Your recorded answer C,D

A - No, a class declaration may include multiple interfaces.
B - No, all methods in an interface are implicitly public.
C * Yes, all methods in an interface are implicitly public, no matter how the interface itself is declared.
D - No, interfaces may define static final variables.

Why is D not right? How should the word "may" be interpreted? I think "may not contain" means it is not compulsory.
Had it been "must not contain" then its incorrect about interfaces, hence not in the answer.


SCJP 6
How To Ask Questions On Java Ranch - How To Answer Questions On Java Ranch
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
I think interface does not contain any variable, they contain constants only, and constants are not variables.


SCJP 6
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Now that's a whole new way of looking at the question.........
Do such type of questions come up in the actual exam where questions(or answers) are ambiguous?
I am still not convinced with the reply though.....
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
No, these type of ambiguous questions are not there.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
I can see how "may not contain" could be interpreted as you did, but it means indeed "can not contain" or "must not contain".

I don't think the question is aimed at the difference between variable and constant (which in any case is not a term that's used from a Java specification point of view). Using the term "field" instead of "variable" might have been a bit clearer.

You might want to alert William (who's a moderator here) to this discussion.


Ping & DNS - my free Android networking tools app
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
Thanks for your replies
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface question