aspose file tools*
The moose likes Java in General and the fly likes How do I extend and implement same method from an abstract class and interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I extend and implement same method from an abstract class and interface" Watch "How do I extend and implement same method from an abstract class and interface" New topic
Author

How do I extend and implement same method from an abstract class and interface

Ravindra Suroju
Greenhorn

Joined: Mar 11, 2008
Posts: 14
I have a method with same signature (arguments & return type) in an abstract class and interface. I want to extend the abstract class and implement the interface in a single class. how can I do that.... please help

Code:

interface Acceptable {
public void accept ();
}

public abstract class AbstractAccept {
public abstract void accept (); // updated the code, forgot to add abstract first time
}

public class ConcreteAccept extends AbstractAccept implements Acceptable {
//// implementation code goes here
}


Best Regards,<br />Ravindra.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

What have you tried so far? What's your first guess?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ravindra Suroju
Greenhorn

Joined: Mar 11, 2008
Posts: 14
Tried to implement both the methods as a same method. as below but it is throwing a NoClassDefFoundError

Code: //
public class test extends AbstractAccept implements Acceptable {
public void accept(){
System.out.println("running Successfully");
}
public static void main (String[] args) {
(new test()).accept();
}
}
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags. Unformatted code/config/etc. is difficult to read. You can edit your post to include them using the button or re-post the question with proper formatting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I extend and implement same method from an abstract class and interface
 
Similar Threads
Abstract and Interface
When to use abstract class instead of interfaces
interface and abstract methods with the same name
Doubt in Interface
Interface assignments