abstract class Animal {
private String name;
public Animal() {
this.name = "someName";
}
public String getName(){
return this.name;
}
}
class Dog extends Animal {
private String breed;
public Dog() {
// super(); <----- not calling it
this.breed = "someBreed";
}
}
public class TryOO {
public static void main(String[] args) {
Dog dog = new Dog();
System.out.println(dog.getName());
}
}
OUTPUT
someName
it looks like it has set the variable without calling super() from Dog?
It looks like no need to call super() if both abstract class and the class which extends it takes no parameter in their constructors.
Is this true?