In Java which one to use Abstract Class or Interface ?

Discussion in 'Java Language Basics/Fundamentals' started by shineveramya, Nov 24, 2008.

  1. shineveramya

    shineveramya New Member

    - Use Abstract Class if you're sure that there can be more specialized subclasses of Abstract Class and there is really a logic is a relationship.

    - Dont use Abstract Class just for code reuse.

    - Use Interface to encapsulate behaviour and let concrete subclasses to implement that behaviour.

    - An alternative approach could be to use Abstract Class to have common implementation and for the behaviour which is gonna very use composition for the varying behavior.
     
  2. anneroberts

    anneroberts Member

    Java doesn't accept assorted inheritance; thus, you cannot accept a chic that accouterments two abstruse classes at once. ... An interface is bigger than a abstruse chic back you demand assorted classes to apparatus that interface and back you don't accept to accede absence behavior.
     

Share This Page