An instance of an object in Java is created every time you use the new keyword. For example,
MyClass myObject1 = new MyClass("John", 1, 1000.20);
MyClass myObject2 = new MyClass("Mary", 2, 200);
MyClass myObject3 = new MyClass();
However, you can only instantiate a concrete class and never a abstract class. So a question arises, what's the point in having an abstract class?
You have a abstract class to provide a common set of functionalities which can be shared by all its subclasses, e.g., attributes, fields, etc.
And of course, an abstract can have a constructor. If you don't provide a constructor explicitly, it will have a default constructor. Whenever one of its concrete subclasses is instantiated, the constructor of the subclass will call the super constructor before doing any type of work in its own constructor. For example,
public abstract class MyAbstractClass {
private String name;
private int age;
public MyAbstractClass() {
name = "bozo";
age = 5;
}
public MyAbstractClass(String name, int age) {
this.name = name;
this.age = age;
}
...
}
public class MyClass extends MyAbstractClass {
private double income;
public MyClass() {
//calls super() implicitly.
}
public MyClass(String name, int age, double income) {
//calls super explicitly
super(name, age);
this.income = income;
}
}