It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubt in abstract class" Watch "doubt in abstract class" New topic

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é

Joined: Nov 24, 2005
Posts: 14688

Abstract class has a constructor

Who is going to implement your abstract methods ?

[My Blog]
All roads lead to JavaRanch
Ken Liao

Joined: Dec 15, 2008
Posts: 13
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

Joined: Oct 13, 2005
Posts: 46397
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.
    I agree. Here's the link:
    subject: doubt in abstract class
    It's not a secret anymore!