Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstact or to Interface?!

 
Gabe Newell
Greenhorn
Posts: 19
  • 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
  • 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: 1840
Eclipse IDE Java Ruby
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic