GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 357 of 436    Print  
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?

  
Total Answers and Comments: 4 Last Update: January 25, 2007     Asked by: Imran Arshad 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 07, 2006 13:44:25   #1  
akulanaveenkumar Member Since: September 2006   Contribution: 2    

RE: If we can'nt make the object of abstract class wha...
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
 
Is this answer useful? Yes | No
September 13, 2006 18:24:25   #2  
prudhviram Member Since: September 2006   Contribution: 11    

RE: If we can'nt make the object of abstract class wha...
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).
 
Is this answer useful? Yes | No
September 13, 2006 18:28:29   #3  
prudhviram Member Since: September 2006   Contribution: 11    

RE: If we can'nt make the object of abstract class wha...
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.
 
Is this answer useful? Yes | No
January 25, 2007 17:18:57   #4  
Sreedhar        

RE: If we can'nt make the object of abstract class wha...
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.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape