• 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 Ques

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of these statements about Interfaces are true ?
a) Interfaces are abstract by default.
b) An Interfaces can have static members.
c) All methods in an interfaces are abstract although you need
not declare them to be so.
d) Fields of an Interface may be declared as transient or
volatile but not Synchronized.
e) Interfaces cannot be final.
Answer given are a and c.
My question is why not e ?
Interfaces are abstract so they cannot be final.
Pls. clarify this.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

b) An Interfaces can have static members.
e) Interfaces cannot be final.
I think the answer should be a, b, c, e.
b) is right because interfaces can define constance and they are public static and final
e) is correct because interfaces are abstract and therefore can not be final Mugal's book page 111, states this explicitly.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think a,b,c are right..
interfaces cannot be final becasue that will mean that one can't extend an interface under any circumstances , which is not possible.. and not mentioned anywhere in JLS.. i guess..
------------------
Hima
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the choice b, if it is member variables in an interface then they are public, static and final, even if not stated. However, interface cannot have static member functions.
 
Ishaan Mohan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic