• 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

Can an interface be private or protected.?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
I have two questions:
1) Can an interface be private or protected. and
2)
if i have an interface
public interface Myintf
{
public abstract void myMeth();
}
If i have a class implementing Myintf should the implementing method have the signature
public abstract void myMeth() or is it okay if it is
public void myMeth()
the implication being that in the first case, the class might itself have to be declared abstract or an interface.
Regards
Ramesh
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Can an interface be private or protected.
Interfaces can be private in nested contents.
and
2)
if i have an interface
public interface Myintf
{
public abstract void myMeth();
}
You are not required to places abstract keyword in method declaration because they abstract implicitly.
You will have to override this method in your subclass and provide your own definition there should be no abstract keyword in that overriden method.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Val
you said "Interfaces can be private in nested contents."
Can you please explain it with example.I was in the assumption
interface will always be public.
Thanks in advance.
Cheers
Lala

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic