File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Constructor 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 "Constructor in abstract class" Watch "Constructor in abstract class" New topic

Constructor in abstract class

mohan shetty

Joined: Oct 26, 2007
Posts: 9
Hello All,

Actually what is the use of having a constructor in an abstract class?
Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31
when sub class implementing the abstract class,before subclass constructor is invoked, it calls the constructor in abstract super class.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
As mentioned, a constructor is required in an abstract class, to allow the concrete subclass to be instantiated.

However, not all possible access modifiers make sense for the constructor of an abstract class. The "public" modifier doesn't in practice offer any more access than "protected". The "private" modifier makes instantiation of a concrete subclass impossible; this only makes sense for a non-instantiable utility class (which is not very OO).

Normally, therefore, the constructor of an abstract class will be "protected". Occasionally, it might be package-private.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Constructor in abstract class
It's not a secret anymore!