This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstact or to Interface?!

 
Gabe Newell
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this thread for a Realy Good Explination (TM) for interface and abstract classes. (Of course, this is just my humble opinion )
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic