This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg.Interface declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg.Interface declaration" Watch "Reg.Interface declaration" New topic
Author

Reg.Interface declaration

sudha
Greenhorn

Joined: Oct 30, 2000
Posts: 4
Hi
Please go thru the following:
I got this doubt when Iam going thru one of the mocks.
interface question {
method();
}
interface question {
int i=3;
}
What are the possible access modifiers for the method in the interface and for the variable declared in the Interface declaration?
I have read that methods are implicitly public,static and abstract by default.Are there any more access modifiers?
Thanks in Advance
Priya
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
The best way to findout the answer - write some CODE!!
Take a look at this program

When you compile this, you will get the following error -

AccessTest.java:3: Interface methods can't be native, static, synchronized, final, private, or protected : void doSomething()
private void doSomething() ;


[This message has been edited by Ajith Kallambella (edited October 30, 2000).]


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
'sudha',
PROPER NAMES ARE NOW REQUIRED!!
Read this post for more details.
Javaranch appreciates your cooperation to comply with the official naming policy.
Ajith
sudha
Greenhorn

Joined: Oct 30, 2000
Posts: 4
hi ajith
Thanks for the info.
I had done the same forinterface variables also.
Interface varibles can be public,static and final.But not transient,volatile,private and protected.
Interface methods can be public and abstract.But not private,protected,static,final,synchronized,native.
Hope Iam correct.
Thanks and Regards
Sudha
 
 
subject: Reg.Interface declaration