When do you absolutely have to declare a class as abstract ?

(as opposed to free-willed educated choice or decision based on UML diagram)?  When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

Showing Answers 1 - 12 of 12 Answers

SONI

  • Sep 12th, 2011
 

When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

In your s/w u come across a family of related with common and some uncommon behavior then go for abstract class
example:common behavior like you have animal namespace that contain fox,Elephant,Dog.All classes having common behavior like walk.sleep,eat but way to perform action is different.

Uncommon: uncommon behavior like sound (sound is different for each),eat(some animal are vegetarian and some are non-vegetation)
other :

In Hospital project Nurse,Doctor,Receptionist contain same name method may be with different. code(EX:GetEmployename,Getsalary etc.)

  Was this answer useful?  Yes

When you do not want to create an object of the class and want to provide some abstract implementation

ex: Class HumanBeing. No Point of creating a class human being. You can create Men or Women out of it an create an object of the derived class

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions