• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Interface Concept in anonymous classes///

 
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?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!