I think the output should be "cougar c f", since calling Cougar()
should just print cougar and call to go()
should print 'c' for this.type
and 'f' for super.type
, since super keyword is used to call the parent class.
Can anyone please verify this?
class Feline {
public String type = "f ";
public Feline() {
System.out.print("feline ");
}
}
class Cougar extends Feline {
public Cougar() {
System.out.print("cougar ");
}
void go() {
type = "c ";
System.out.print(this.type + super.type);
}
public static void main(String[] args) {
new Cougar().go();
}
}