[ad_1]
So the quick answer, the output will be
feline cougar c c
The reason now.
new Cougar() will create an instance Cougar, since a Cougar is a Feline, Feline‘s constructor is the first thing called in the Cougar‘s constructor.
This explain “feline cougar”.
public Cougar() {
System.out.print("cougar ");
}
is actually looking like
public Cougar() {
super(); //printing "Feline"
System.out.print("cougar ");
}
Now, this.type and super.type both access the same variable declared in Feline.
Since you assign "c" to it, this explain the output “c c”
[ad_2]
solved Explain the output of the java program [duplicate]