Given:
And given the code fragment:Which two modifications enable the code to print the following output?
Canine 60 Long
Feline 80 Short
A.
Replace line n1 with:
super ();
this.bounds = bounds;
B.
Replace line n1 with:
this.bounds = bounds;
super ();
C.
Replace line n2 with:
super (type, maxSpeed);
this (bounds);
D.
Replace line n1 with:
this (“Canine”, 60);
this.bounds = bounds
E.
Replace line n2 with:
super (type, maxSpeed);
this.bounds = bounds;
The correct answer is A,E.
Answer: A, E
package q027;
class Animal {
String type = “Canine”;
int maxSpeed = 60;
Animal(){}
Animal(String type, int maxSpeed) {
this.type = type;
this.maxSpeed = maxSpeed;
}
}
package q027;
class WildAnimal extends Animal {
String bounds;
WildAnimal(String bounds){
//line 1
super();
this.bounds = bounds;
}
WildAnimal(String type, int maxSpeed, String bounds) {
//line 2
super(type, maxSpeed);
this.bounds = bounds;
}
public static void main(String[] args) {
WildAnimal wolf = new WildAnimal(“Long”);
WildAnimal tiger = new WildAnimal(“Feline”, 80, “Short”); //Argument “Short is missing in the question
System.out.println(wolf.type +” “+ wolf.maxSpeed +” “+ wolf.bounds);
System.out.println(tiger.type +” “+ tiger.maxSpeed +” “+ tiger.bounds);
}
}
Output:
Canine 60 Long
Feline 80 Short
A E