File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes iterface method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "iterface method" Watch "iterface method" New topic

iterface method

tribhuwan soni

Joined: May 23, 2007
Posts: 6
hi buddy,

if giving more than one body of abstract method in interface when want to implement it in the class could it possible to define only ane abstract method and other not using in the class even keep it only body.

tribhuwan soni
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

Tribhuwan, I'm sorry but it's hard to follow what you mean. Can you post some code to explain what it is exactly that you want to know?

In an interface, you cannot specify a body for a method. When you create a non-abstract class that implements an interface then all methods of the interface must be implemented in the class.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
I think I get what you're asking. I believe what you're trying to ask is whether an abstract class that implements an interface must give implementation code for all of the methods in the interface. (If this isn't right, feel free to correct me.)

The answer is no, but any class that extends the abstract class must implement the methods that the abstract class does not.

For example:

The interface A defines two methods. The abstract class B implements one of them, and the concrete class C implements the other.

Does this answer your question?
I agree. Here's the link:
subject: iterface method
It's not a secret anymore!