Answered step by step
Verified Expert Solution
Link Copied!

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); //

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions