Abstract Class:
1. Abstract Class Can contain Abstract Methods and Non-
Abstract Methods.
2. When a Non-Abstract Class is Inherited from an Abstract
Class, the Non-Abstract Class should provide all the
implementations for the inherited Abstract Method.
Interface:
1. Interface is nothing but Pure Abstract Class ie
Interface can contain only the function declaration.
2. All the members of the interface are Public by Default
and you cannot provide any access modifiers.
3. When a class is inherited from the interface, the
inherited class should provide actual implementations for
the inherited members.
Interviews4 answers
what diff b\w abstract and interface? when will go for abstract& interface
4 Answers
Harshit VyasPosted Nov 10, 2010, 7:18 PM EST
Abstract and interface both are similar
but some difference
but some difference
raj guptaPosted Oct 30, 2010, 9:00 AM EDT
When there is a need to inheritance then abstract class should be used.
And When there is need to common functionality implementation by more then one class then Interfaces should be used.
And When there is need to common functionality implementation by more then one class then Interfaces should be used.
prakash gajeraPosted Oct 27, 2010, 7:14 AM EDT
Abstract class contains pure virtual function and must/can be inherited by the derived class to implement inheritance.
Where as Interface contains only definition of the functions and must/can be implemented by any other class.
Where as Interface contains only definition of the functions and must/can be implemented by any other class.
prakash gajeraPosted Oct 27, 2010, 7:11 AM EDT
