2

Possible Duplicate:
Abstract class constructor in Java

When we can't create an instance of abstract class, what is the purpose of a constructor?

Community
  • 1
  • 1
GuruKulki
  • 25,776
  • 50
  • 140
  • 201

2 Answers2

6

You can still extend the abstract class and call the abstracts class' constructor in your derived class.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
0

I often create a constructor with some parameters (and don't create empty constructor) in abstract class and in this way I make all subclasses to have constructor with all these parameters. This approach guarantees that subclasses are initialized correctly.

But in my last few projects I use spring with its dependency injection for this purpose.

Roman
  • 64,384
  • 92
  • 238
  • 332