• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding interface

 
laxmidhar prad
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir,If interface has got four methods,and I like to implement only two methods, how this could be achieved?
 
Jody Brown
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mark the class implementing the interface as abstract, you only need to provide either partial, or default implementations of the method stubs defined in the interface. This type of class is typically called an Adapter. The remaining methods will then need to be implemented fully in a concrete subclass that inherits from this Adapter.

Be aware however, that by marking a class as abstract, you cannot instantiate it. You will have to instantiate a concrete subclass that has implementations of all of the methods defined by the interface.
 
Matt Harrah
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eventually, instantiated classes that implement the interfaces must have a method that implements the methods on the interface.

However, if the methods on the interface do not apply in a particular situation or should not be called on a specific class that implements that interface, you can do this:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic