Which two modifications enable the code to print the following output?

Given:

And given the code fragment:

Which two modifications enable the code to print the following output?
Canine 60 Long
Feline 30 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;

Download Printable PDF. VALID exam to help you PASS.

3 thoughts on “Which two modifications enable the code to print the following output?

  1. upper line to //n2 its needed to correct “WildAnimal” constructor to this form:
    WildAnimal (String type, int maxSpeed, String bounds)

    With “A”and “E” program will be compiled and result will be:

    # javac Test42.java
    # java Test42
    Canine 60 Long
    Feline 80 Short

  2. Answer are A and E

    public class Test {

    public static void main (String[] args){
    WildAnimal wolf = new WildAnimal(“Long”);
    WildAnimal tiger = new WildAnimal(“Feeline”, 80, “Short”);
    System.out.println(wolf.type + ” ” + wolf.maxSpeed + ” ” + wolf.bounds);
    System.out.println(tiger.type + ” ” + tiger.maxSpeed + ” ” + tiger.bounds);
    }
    }

    class Animal{
    String type = “Canine”;
    int maxSpeed = 60;

    Animal(){}

    Animal(String type, int maxSpeed){
    this.type = type;
    this.maxSpeed = maxSpeed;
    }

    }

    class WildAnimal extends Animal{
    String bounds;

    WildAnimal(String bounds){
    super();
    this.bounds = bounds;
    }

    WildAnimal(String type, int maxSpeed, String bounds){
    super(type, maxSpeed);
    this.bounds = bounds;
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.