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.
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!
Joined: Sep 14, 2000
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.
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.