See this thread for a "world of nature" example of interface vs. abstract class.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Herb Schildt
Author
Ranch Hand
Joined: Oct 01, 2003
Posts: 239
posted
0
Here are two general guidelines that might help: First: An interface cannot contain any implementation whatsoever. (Thus, all methods are abstract.) An abstract class can contain as much implementation as you desire. (For example, an asbstract class can contain one or more fully implemented methods.) Therefore, if you want to supply a partial implementation, use an abstract class. Otherwise, use an interface. Second: A class can implement multiple interfaces. It can only inherit one abstract class. Thus, if you want a class to be able to implement two or more "interfaces", they must be interfaces, not abstract classes.
For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
Adrian Yan
Ranch Hand
Joined: Oct 02, 2000
Posts: 688
posted
0
Correct me if I'm wrong. To me, interface in java is about as close as java gets with multiple inheritance, remember, java doesn't allow multiple inheritance. However, interface allows you to do that in a sense.