If we can'nt make the object of abstract class what is the use of defining of data members and non abstract functions in that abstract class?

Showing Answers 1 - 6 of 6 Answers

akulanaveenkumar

  • Sep 7th, 2006
 

Hi, This is naveenkumar,a for to maintaing some abstraction levels in the class which is abstract suppose in a project there may be more than one person includesall of them should use one of the method, then make the super clas as abstract

  Was this answer useful?  Yes

prudhviram

  • Sep 13th, 2006
 

Eventhough you cant create an instance of abstract class you can create an instance of its super class which inherits the members of the abstract class(sub class) and you can write you code in the data members/methods in super class. You can derive multiple classes from a single abstract class and you can take advantage of the methods that are defined in abstract class.Remeber "abstract" itself implements hiding implemention details and hence abstract class(hide/restrict the implementation details of all its members).

  Was this answer useful?  Yes

prudhviram

  • Sep 13th, 2006
 

Eventhough you cant create an instance of abstract class you can create an instance of its super class which inherits the members of the abstract class(sub class) and you can write you code in the data members/methods in super class. You can derive multiple classes from a single abstract class and you can take advantage of the methods that are defined in abstract class.Remeber "abstract" itself implies hiding implemention details and hence abstract class(hide/restrict the implementation details of all its members). For Example: Assume Car is an abstract class with Odometer,Cruise as its members.In MaruthiCar which extends Car can include(define code for) Odomenter in it. In Honda Car Which extends car You can include(define code for) both Odometer and Cruise.

  Was this answer useful?  Yes

Sreedhar

  • Jan 25th, 2007
 

Its basically for Polymorphism, So that we can call same method on different classes based on the subtype.Say you implement a factory and get back the subclass requried, then u can call the method without any issue as all the subclassed implment the same abstract 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