aspose file tools*
The moose likes Beginning Java and the fly likes abstract vs interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "abstract vs interface" Watch "abstract vs interface" New topic
Author

abstract vs interface

sarada konda
Greenhorn

Joined: Dec 10, 2004
Posts: 7
Abstract class statisfies all the needs of interface.i.e

interface Test1
{
void method1();
void method2();
......
}
can be replaced with the following abstract calss

abstract class Test{
abstract public void method1();
abstract public void method2();
....
}

so then can any tell me what's the use of interface. thanks in advance
Sree Nivas
Ranch Hand

Joined: Jul 24, 2003
Posts: 95
Go thru the folloing URL:

http://mindprod.com/jgloss/interfacevsabstract.html

Sree Nivas
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
and simply use the search function here.

It seems every time a Java course begins at a school somewhere and they get to inheritance half the students post this exact same questions (with slightly different wording) here and in every other Java forum worldwide.


42
louise rochford
Ranch Hand

Joined: Apr 04, 2002
Posts: 119
In case it helps...

I'd start to design a code solution using interfaces, then change an interface into an abstract class if I could see particular benefits. If an abstract class just as easily be an interface - make it an interface. It'll make your code more reusable / flexible in the future.

Regards, Louise
sarada konda
Greenhorn

Joined: Dec 10, 2004
Posts: 7
I know the interface has one major adv over abstract class i.e
interface -> a class can implement more than one interface
abstract class -> a class can extend only one abstract class
apart from this is there any major advantage of using interface instead of abstract class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract vs interface