wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Abstact or to Interface?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstact or to Interface?!" Watch "Abstact or to Interface?!" New topic
Author

Abstact or to Interface?!

Gabe Newell
Greenhorn

Joined: Dec 07, 2004
Posts: 19
Hi guys,

I have been tucking into my Deitel book: "How to program Java" and I have a question to be clarified.

My question is: when to use abstract classes and interface??! The book doesn't really clarify the difference between them. Can anyone help me out?

Many thanks in advance,

- The Atomic Moonfrog
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Advantage of interface: You can implement any number of interfaces while you can only extend one class.

Advantage of abstract class: You can supply the implementation of some methods but not others. Interfaces cannot supply any method implementations.

There is a lot more here if you search on the terms "abstract" and "interface".


Mike Gershman
SCJP 1.4, SCWCD in process
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Check out this thread for a Realy Good Explination (TM) for interface and abstract classes. (Of course, this is just my humble opinion )


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
This question has been asked a lot before, so you can use the Search tool if you would like more information on it.

Keep coding!

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstact or to Interface?!
 
Similar Threads
Interface doubt from K&B
Access modifer to interface
createRecord()/deleteRecord() methods
interfaces!
Root Interfaces for Collection