[JAVA rookie] on the problem of parameters passed by inherited constructors.

The

code is as follows:

abstract class Animal {
    int age;
    public Animal() {};
    public Animal(int age) {
        this.age = age;
    }
}

class Bird {
    public Bird(int age) {
        super(age);
        System.out.println("");
        System.out.println("" + age + "");
    }
}

class Fish {
    public Fish(int age) {
        super(age);
        System.out.println("5");
        System.out.println("" + age + "");
    }
}

public class Test {
    public static void main(String[] args) {
        Bird bird = new Bird();
        Fish fish = new Fish();
    }
}

the execution result is as follows:

clipboard.png

I don"t see what"s wrong with the program. I passed 1 when I passed the value, how can I say I don"t have parameters?

Jun.18,2021

you didn't write extends
class Fish extends Animal {.}

Menu