If you are never going to instantiate an object from that class, when are you going to ever use its constructor? Sorry if I come off as ignorant. I just started a class on Java at my high school.
-
2The point of a constructor in _any_ class is to initialize the class' state. – Sotirios Delimanolis Oct 30 '14 at 23:09
-
The `Abstract` class may have different initialisation requirements from it's parent class or may need to act as a proxy to them. They can act as a convenience to implementations as well – MadProgrammer Oct 30 '14 at 23:12
4 Answers
you can initialize something in parent class , so maybe you need constructor in abstract class.

- 926
- 10
- 34
Because sub classes may use it. For example:
public abstract class Foo {
protected String name;
public Foo(String name) {
this.name = name;
}
}
public class Bar extends Foo {
public Bar(String name) {
super(name); //<-- necessary, otherwise it won't compile
}
public Bar() {
super("default name"); // <-- necessary, otherwise it won't compile
}
}

- 85,076
- 16
- 154
- 332
You have a constructor so subclasses can initialize the state of their parent properly.
public abstract class Parent {
private final String name;
public Parent(String n) { this.name = n; }
public String getName() { return this.name; }
}
public class Child extends Parent {
public Child(String name) { super(name); }
}
There would be no other way to initialize that private final String name
attribute in the Parent
without a constructor.

- 305,152
- 44
- 369
- 561
Well your parent class or the abstract class stores common variables throught all children classes or subclasses. This makes it easier to store different objects (with the same parent) into collections such as and ArrayList. It also allows you to easily manipulate and object without worrying about its details that is contained in the subclass. You do instantiate the constructor by calling super() within the subclass.