Question: Data structures: java 5. What does the following program print out. Explain why. class Thing f public int a; public public int b; Thing (int

 Data structures: java 5. What does the following program print out.

Data structures: java

5. What does the following program print out. Explain why. class Thing f public int a; public public int b; Thing (int a, int b)(this,a-a; this.b-b} public class Test public static void f (Thing x, int y) x.a++ public static void main(String[] args) Thing x -new Thing(1,1); int y - 1; f(x, y); System . out. print1n("x. a " + x. a + " and x.b System.out.print 1n(" y = " + y) ; " + x. b) ; 6. Suppose that we have classes A, B, C and D. Suppose that B is a subclass of A, that C is a subclass of B, and D is a subclass of A. Suppose that we make the following declarations A a1 - new A); A a2 - new CO; For each part below, explain what, if any, errors would be caused by the statement in that part. Be sure to consider both compile time and run time errors (a) A a3 new B(); (b) B b1 = new A(); (c) B b2 = (B) al; (d) B b3 = (B) a2 ; (e) B b4 (B) dl; (f) B b5-(C) (A)new DO

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 Databases Questions!