File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes doubt in abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubt in abstract class" Watch "doubt in abstract class" New topic
Author

doubt in abstract class

manas ranjan mandal
Ranch Hand

Joined: Apr 02, 2008
Posts: 97
Abstract class has a constructor so why can't we create instance of abstract class?
Thanks in advnace
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Abstract class has a constructor

Who is going to implement your abstract methods ?


[My Blog]
All roads lead to JavaRanch
Ken Liao
Greenhorn

Joined: Dec 15, 2008
Posts: 11
Create a instance need a constructor, but not just only a constructor. All of its components must be defined clearly including abstract method.


A man takes responsibility for his actions, right or wrong - <<Battlestar Galactica>>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
I have a dubious and inaccurate way of thinking of an object. For every object which isn't specifically an Object (note: O/o) it has two components:
  • The part from its own class, and
  • The part from its superclass
  • If the superclass is abstract, you still need to create that part of the object, and that part will (probably) still need its constructor.

    You can actually instantiate an abstract class directly, but only as an anonymous class which is beyond the bounds of the beginner's forum.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: doubt in abstract class
     
    Similar Threads
    A question about container!
    usage of a class
    A mock question
    HttpServlet class
    ABSTRACT