Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 21:34 Oct 09, 2013 |
Anonymous said
The question asked for the output produced by the following code.
Circle c1 = new Circle(3); The line Circle c2 = c1; sets the variables c1 and c2 to refer to the same circle. At this point that circle can be manipulated by using either of the two variables. It's something like the following. Imagine that you deposited $100 to your checking account using an ATM. You then went to a different ATM and asked for the balance in your account. The balance would include the $100 you just deposited even though you referred to the account from two different ATMs. The line c1.setRadius(4); sets the radius of that circle to be 4. The line System.out.println(c2.getRadius()); prints out the radius of that same circle. C1 and C2 are two ways of referring to a single object. In the last question, luckyNumber and luckyNumber2 do not refer to objects. They store integer values. The difference has to do with how you refer to objects vs. how you refer to numbers. Last edited by rabbott at
21:35 Oct 09, 2013.
|
Anonymous
Posts: 166
|
Posted 22:21 Oct 09, 2013 |
Thank you very much. It is obvious right now. |