Question: 12-14 if possible, thanks. (For Data Structures) 12. What does the following program print out. Explain why public class Thing public inta; public int b;
12. What does the following program print out. Explain why public class Thing public inta; public int b; public Thing(int a, int b) this.a-a; this.b-b public class Test public static void f(Thing x, int y) x.a+ y+t; public static void main(Stringl] args) Thing x new Thing( 1,1 ); int y 1 fx, y) System.out.println"x.a-x.ay 13. 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: D d new DO; 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 BO; (b) B bl new A0: (c) B b2 (B) al; (d B b3 (B) a2; (e) B b4 (B) d ( B b5 (CA)new DO: 14. Let A be an array of size n 22 containing integers from l to n-1, inclusive, with exactly one number repeated. Write a method public static int findRepeatedNumber(int] A) that returns the value of the repeated number in the array A
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
