• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reg.Interface declaration

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic