• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in abstract class

 
manas ranjan mandal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract class has a constructor so why can't we create instance of abstract class?
Thanks in advnace
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract class has a constructor

Who is going to implement your abstract methods ?
 
Ken Liao
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a instance need a constructor, but not just only a constructor. All of its components must be defined clearly including abstract method.
 
Campbell Ritchie
Sheriff
Posts: 48374
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic