Originally posted by Raj Joe: When should I go for a abstract class or interface. Can you please give a real world example
In an abstract class can define the methods which are common to all child classes but some functions like StartUp & Shutdown may differ from class to class such function's can be writtern inside a abstract class without a definition and the child class is forced to write that function. But in the case of interface none of the methods can have that implementation.
An abstract class can have all the flavours of class members like private public protected, but interface needs to be public in general.
When two unrelated classes need to implement a common properties we can use interface. Ex: Human , Lorry : both these classes have some common properties like color, Weight.These Color & Weight cannot be in a base class for Class "Human" & Class "Lorry". B'coz if u'r using a base class the classes that extends from this class s'd be logically related to each other.In this case Human & lorry cannot be related logically.