• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can interfaces be instantiated?  RSS feed

 
Dushyant Shukla
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are 100 % abstract classes.They cannot be instantiated.Their sole purpose is to be implemented.So why does the following code works just fine while it is attempting to instantiate an interface.


Please correct me if I am wrong!
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the feature of Java's Anonymous classes.

Detailed explanation is given here.
 
N Sam
Ranch Hand
Posts: 77
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a side note....
Interfaces are 100 % abstract classes.

is not entirely accurate because there are some differences between abstract classes and interfaces.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!