• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

small doubt in interface..

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we create instance for an interface...
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. You can create an instance of an anonymous inner class that implements an interface, but that's really not the same thing, even though it looks like you are instantiating that interface.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interface does not provide any implementation and is, therefore, abstract by definition. This means that it cannot be instantiated, but
classes can implement it by providing implementations for its method prototypes. Declaring an interface abstract is superfluous and
seldom done.

Interfaces with empty bodies are often used as markers to tag classes as having a certain property or behavior.
Example : java.lang.Cloneable, java.io.Serializable,
java.util.EventListener.
 
reply
    Bookmark Topic Watch Topic
  • New Topic