Answers for "how to overload constructor in abstract class"

0

how to overload constructor in abstract class

abstract class Product { 
    int multiplyBy;
    public Product( int multiplyBy ) {
        this.multiplyBy = multiplyBy;
    }

    public int mutiply(int val) {
       return multiplyBy * val;
    }
}

class TimesTwo extends Product {
    public TimesTwo() {
        super(2);
    }
}

class TimesWhat extends Product {
    public TimesWhat(int what) {
        super(what);
    }
}
Posted by: Guest on October-19-2021

Code answers related to "how to overload constructor in abstract class"

Browse Popular Code Answers by Language