Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface question

 
sreedhar lak
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt in the answer for the below.I read this question from one mock exam.
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.



Correct option "C"
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

They provided check box ,to select multiple.
My options are C,D
Please tell me Wht is my mistake
Thanks a lot
 
Bastin Gomez.H
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the variables in an interface are by default - public, static & final. Since it is final, the value cannot change. So it acts as a Constant.
 
Graham Walsh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

while it's not the right answer, what is this statement suggesting? I know its not the right answer but can somebody show me an example of code that
does what this sentence states. Its a question of wording for me. I don't see what they're trying to convey.

A - No, a class declaration may include multiple interfaces.


Originally posted by Bastin Gomez.H:
All the variables in an interface are by default - public, static & final. Since it is final, the value cannot change. So it acts as a Constant.


thanks

G
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic