Question: Given the following classes definitions, what does the following statement print to the console: X myx = new 20: class X{ protected int x1=1; protected


Given the following classes definitions, what does the following statement print to the console: X myx = new 20: class X{ protected int x1=1; protected int x2=2; public XIX System.out.println("Executing X first constructor"); } public X(int x1, int x2X System.out.println("Executing X second constructor"); this.x1=x1; this.x2-x2; } class Y extends X{ protected double y1; public YOX this(1.5); System.out.println("Executing Y first constructor"); } public Y(double y1) super(2,4); System.out.println("Executing Y second constructor"); class Y extends X{ protected double y1; public YOK this(1.5); System.out.println("Executing Y first constructor"); } public Y(double y1X super(2,4); System.out.println("Executing Y second constructor"); this.y1=y1; } ) class Z extends Y { public ZOK System.out.println("Executing Z first constructor"); } Select one 9.Executing X second constructor Executing first constructor Executing Y second constructor } class Z extends Y { public ZOE System.out.println("Executing Z first constructor"); } Select one: O a Executing X second constructor Executing Y tirst constructor Executing Y second constructor Executing 2 first constructor b. Executing x first constructor Executing Yfirst constructor Executing Z first constructor O c. Executing X second constructor Executing Y second constructor Executing first constructor Executing Z first constructor O d.Executing Z first constructor e. It does not print anything because it causes a syntax error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
