Hi
There is no such thing as a virtual constructor in Java. Since constructors are related to a particular instance the following rules apply:
Constructors can't be abstract, native, static, synchronized or final.
However, Java does not prevent you from defining a non-abstract constructor in an abstract class. Note that you cannot instantiate an abstract class but you can use it as follows
in a class hierarchy:
The following code illustrates the assigment of a non-abstract
subclass to an abstract superclass. So you can't have abstract
constructors directly but in this sense it works fine.
public abstract class AbstractTest {
int i;
public AbstractTest(int i) {
this.i = i;
}
public static void main(
String [] args) {
AbstractTest
test = new AbstractTestChild(1);
}
}
class AbstractTestChild extends AbstractTest {
public AbstractTestChild(int i) {
super(i); //works
}
}
Hope that this helps
Regards
Jakob