If the superclass doesn’t have a default constructor, then the subclass also needs to have an explicit constructor defined. Otherwise, it will throw a compile-time exception. In the subclass constructor, a call to the superclass constructor is mandatory in this case, and IT SHOULD BE THE FIRST LINE IN THE SUBCLASS CONSTRUCTOR.
Does the highlighted part still hold in JDK 25?
I checked multiple online resources and verified it with AI. According to both, the statement above is indeed true.
But I encountered a contradiction, as the following part, even after having super as the second line, runs fine.
public Cat(boolean veg, String food, int legs, String color){
this.color=color;
super(veg, food, legs);
}