• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface Concept in anonymous classes///  RSS feed

 
Linga Sharath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




/// My doubt is " as per interface concept we must and should implement all the methods present in interface should implement by the class. In one rare case there are "N"- no of methods in interface but i want to implement only some of them.... can we do this without implementing other methods of interface?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch

Please use CODE tag while posting your code,so that it can be readable.

Linga wrote:
In one rare case there are "N"- no of methods in interface but i want to implement only some of them.... can we do this without implementing other methods of interface?


1.Create one AbstractInterface and provide some default implementation[or throw UnsupportedOperationException] for those methods which are not going to use in a Concrete class(Let say X) . and X extends AbstractInterface instead of Interface

2. or Implements all the mothod and throw an UnsupportedOperationException from the methods which are not neccessary
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!