GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 411 of 502    Print  
Why can't we create object for an abstract class?

  
Total Answers and Comments: 5 Last Update: August 10, 2009     Asked by: ramesh 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 27, 2007 03:46:45   #1  
sure.duggirala Member Since: June 2007   Contribution: 3    

RE: Why can't we create object for an abstract class?

An abstract class is a class which doesnt have an implementation for one or more methods. It means that the jvm doesnt have any direction of what to do in case if someone calls the method which is abstract. So if you are able to create an object for the abstract class and call any abstract method of it the jvm will not be able to decide what to do and hence it my be crashed. So to avoid this situation we are restricted to instantiate a abstract class. If you need a object for that abstract class create a concrete subclass and create an object for it and use it.


 
Is this answer useful? Yes | No
August 03, 2007 05:54:53   #2  
sujatham Member Since: January 2006   Contribution: 142    

RE: Why can't we create object for an abstract class?

An abstract class can include concrete methods and fields. In fact an abstract class does not need to include any abstract methods. The abstract modifier simply indicates that the class cannot be instantiated.


 
Is this answer useful? Yes | No
September 19, 2007 07:51:27   #3  
Amit Patil        

RE: Why can't we create object for an abstract class?

We cant create an object for object class as it is supposed to be used in inheritance heirarcy. Abstract class may contain abstract methods which the inheriting class should implement. The abstract class may not contain abstract methods but is defined abstract just to prevent instantiation


 
Is this answer useful? Yes | No
February 14, 2008 02:54:57   #4  
sampra Member Since: February 2008   Contribution: 278    

RE: Why can't we create object for an abstract class?
beacuse abstract class has not complte body ie class status is not clear so we cant create object
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
August 09, 2009 23:46:11   #5  
luffykun Member Since: August 2009   Contribution: 2    

RE: Why can't we create object for an abstract class?
To create objects we generally use new keyword mentioning indirectly the size to allocate the memory.
We do not know the size occupied by abstact methods so we cannot create object for abstract methods.

 
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