Question: Given the code below, answer the following: 1. (+1) In statement 1, which Java rule allows us to use a reference of a type different

Given the code below, answer the following: 1. (+1) In statement 1, which Java rule allows us to use a reference of a type different from the object type? 2. [+2] In statement 1, trace the chain of constructors being called by Chicken(50), i.e. list all constructors from all classes that were called by this statement and indicated their order of execution and what each constructor does. Make sure to refer to how super is used in this process. 3. [+2] In statement 2, write the expected output and explain how dynamic binding works to produce that output. public class Test public static void main(String[] args) { Displayable d = new Chicken(50); //1 d.display(); 1/2 3 1 public interface Displayable{ void display(); public abstract class Animal implements Displayable { private int x,y; public Animal(){X-8; y=6;} public Aninal(int x, int y) {this.x = x; this.y = y;} 3. [+2) In statement 2, write the expected output and explain how dynamic binding works to produce that output public class Test public static void main(Strinel] args) { Displayable d = new Chicken(50); // d.display(); 1/2 1 public interface Displayable void display(); } public abstract class Animal implements Displayable { private int x, y: public Animal(){x=8; y=8;) public Animal (int x, int y){this.x = x; this.y = y;) public class Bird extends Animal private int weight; public void displayO{System.out.println("Bird");} } public class Chicken extends Bird private int energy public Chicken(int energy){this.energy = energy;) }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
