• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Interface question

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bring out your dead! Or a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic