Question: Given the following classes: public class A { private int x = 1; private int y = 2; public int m) { } return

Given the following classes: public class A { private int x = 

Given the following classes: public class A { private int x = 1; private int y = 2; public int m) { } return x + y; public int x() { return x; } } public class B extends A { private int x = 300; private int z = 400; public int m() { return super.m() +z; } public int x2() { return 2 this.x(); } } Consider the following code: A a1 = new A(); A a2 new B(); Ba3 new B(); For each expression below, indicate the current type of the reference in front of the dot, the true type, and the result of the expression. Write Illegal" for the result if the expression is not allowed. EXPRESSION 1) al.m 2) a2.m 3) a2.x20 4) ((B)a2).x20) 5) a3.x20 CURRENT TYPE TRUE TYPE RESULT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!