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
posted
0
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
posted
0
'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
posted
0
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