It's not a secret anymore!*
The moose likes Beginning Java and the fly likes regarding interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding interface" Watch "regarding interface" New topic
Author

regarding interface

laxmidhar prad
Ranch Hand

Joined: Feb 05, 2006
Posts: 33
sir,If interface has got four methods,and I like to implement only two methods, how this could be achieved?
Jody Brown
Ranch Hand

Joined: Nov 09, 2005
Posts: 43
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

Joined: Aug 05, 2006
Posts: 54
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
 
subject: regarding interface
 
Similar Threads
What is advantage of marker interface?
access modifier of interface method
Interface
SortNames Requirements
printing...static context?