• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg.Interface declaration

 
sudha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic