• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

on interfaces..

 
ramani2020
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody..
I have started preparing for SCJP2 right earnestly.
could somebody confirm these?
in an interface:
1. Member methods are implicitly public and abstract.
2. Member methods cannot be
static,native,private,protected,final,or synchronized.
3. Fields in an interface cannot be private or protected.
4. A class or a field declared in an interface is implicitly
static and public.
am I right?
anything that I missed out in this?
Thanks for your help.
Ramani.

 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at http://rita_i.tripod.com/modifiers.htm
(But this is a beta-version, so if you find any mistakes, please, inform me... )
 
Serge Plourde
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramani,
I'll try my best to answer you.
From the JLS (Java Language Specification):
All interface members are implicitly public.
... Every field (constant) declaration in the body of an interface is implicitly public, static, and final.
... Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block.
...Every method declaration in hte body of an interface is implicitly public... Note that a method delcared in an interface must not be declared static... because static methods cannot be abstract... it can not be native or synchronized.. it can not be declared final.
Looks like you are all right!
 
ramani2020
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot, Mapraputa and Serge ..
Mapraputa, the link you gave is useful.
Let me check out whether they are all correct..I like to learn from my own simple codes!
thanks for confirming ,Serge..
regards,
Ramani.
 
srikrish
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mapraputa,
I was going through the chart for modifiers that you had created. For interface variables, shouln't the static column have 'D' instead of '+', since all interface variables are static, public and final by default?
Pl. let me know if I'm wrong.
Srikrish.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic