My code –
public abstract class Level1Class
{
protected double num = 0.0D;
protected Level1Class(){}
protected Level1Class(double num){this.num = num;}
protected abstract methods A, B, C...etc //pseudocode !
}
public class Level2Class extends Level1Class
{
//NO CONSTRUCTORS HERE
//BUT, only implementation of methods A,B, C
}
public class Tester
{
Level2Class l2c = new Level2Class(10.0D); //This causes the compiler error !
}
Can someone tell me why I get this error. I know it will go if I create the necessary constructor in Level2Class. But, I want to know the reason.
Level2Classhave a only default constructor which would be implemented by compiler.Level2Classdoes not have constructor which takes double as parameter.This will try to figure out double constructor in
Level2Classclass which is not available because constructor are not inherited.