Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4) Assume that the following statements are executed in some method: int a = 42; Rectangle rect = new Rectangle (10, 20, 30, 40); //
4) Assume that the following statements are executed in some method: int a = 42; Rectangle rect = new Rectangle (10, 20, 30, 40); // (x, y, width , height) We can then sketch a "memory map" showing the values of the local variables at this point. For a primitive type like int, the variable stores the actual value. For an object, the variable stores a reference to the object (which is somewhere else in memory) Rectangle rect y 20 width 30 height |40 a 42 (local variables) Then, trace execution of the remaining statements below. Sketch what the memory map looks like after all statements have executed, and show what the output is from the println ) statements Rectangle rect2 = new Rectangle (2, 4, 6, 8); int b = a; Rectangle rect3 = rect; rect3.setWidth (99); rect2. setX (137); b=b+5; System. out.println (a);' System. out.println (b); System. out.println (rect.getwidth ))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started