This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "abstract class" Watch "abstract class" New topic

abstract class

varungoyal goyal
Ranch Hand

Joined: May 31, 2006
Posts: 37
can we declare a constructor of abstract class in any case.
Kia Phia Ben
Ranch Hand

Joined: Dec 16, 2005
Posts: 48
Hi varungoyal goyal
I think you can create constructor of abstract class when you call it in constructor of subclass
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi varungoyal,

can we declare a constructor of abstract class in any case.

Why do you post this question in a forum?
You can test it yourself in a minute.

Anyway, the answer is yes. Every class - also abstract classes -
MUST have a constructor. If you don't provide one, the default constructor will be used.

Below an abstract class with a constructor, and a concrete class extending the abstract one:


all events occur in real time
I agree. Here's the link:
subject: abstract class
It's not a secret anymore!