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,118
  • 47
  • 138
  • 197

2 Answers2

6

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

Joachim Sauer
  • 291,719
  • 55
  • 540
  • 600
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
  • 61,962
  • 88
  • 232
  • 324