|
Objects
Dec 12, 2001 22:11:32 GMT -5
Post by Sylph on Dec 12, 2001 22:11:32 GMT -5
|
|
|
Objects
Dec 12, 2001 22:37:20 GMT -5
Post by Majin_Blues on Dec 12, 2001 22:37:20 GMT -5
me thinks the 20 is a typo... shouldn't the printout be:
10 0 10
cuz that other method ran?
|
|
|
Objects
Dec 12, 2001 22:50:50 GMT -5
Post by Sylph on Dec 12, 2001 22:50:50 GMT -5
no, they wouldn't leave a typo on an exam answer for ppl to study from. besides, i tried it out, and it was 20.
|
|
|
Objects
Dec 12, 2001 22:54:59 GMT -5
Post by Majin_Blues on Dec 12, 2001 22:54:59 GMT -5
it's 20???
i get the 10 0 part... do you get the 20 part?
(i'll help you if you help me!)
|
|
|
Objects
Dec 12, 2001 22:56:11 GMT -5
Post by Sylph on Dec 12, 2001 22:56:11 GMT -5
*sigh* i only get the 10 0 part.
|
|
|
Objects
Dec 12, 2001 22:58:20 GMT -5
Post by Majin_Blues on Dec 12, 2001 22:58:20 GMT -5
hmm...
maybe the vh doesn't exist outside of the method...
and since v was referring to that, it can't refer to that anymore cuz it disappeared when the method was done...
but this is a whole load of BS... it should be 10!
EDIT: maybe it should be null... the value v refers to disappears because vh was instantiated inside the method that ended
|
|
|
Objects
Dec 12, 2001 23:15:48 GMT -5
Post by Evotamer on Dec 12, 2001 23:15:48 GMT -5
Here's what I think... since someone tried this and got 20 as the second output... When you make ValHold vh = new ValHold() ; and have v = vh; You're pointing v to vh basically for the reference address. After the another method, vh no longer exists, thus the pointer to vh is removed, and v goes back to the last state it was set as, which is v.i = 20.
Make any sense?
|
|
|
Objects
Dec 12, 2001 23:17:58 GMT -5
Post by Sylph on Dec 12, 2001 23:17:58 GMT -5
hmm... but maybe vh is the address, and the address disappears, but the object is still there? so v should still point to the object? ... well, ur first answer fit the description of what happened, even though it didn't make that much sense... maybe i'll just assume it's true, and hopefully it'll apply in the exam situation, but perhaps for different reasons. good luck everyone on the exam! does anyone else find the past exams extremely hard like we're all gonna get killed on this final?
|
|
|
Objects
Dec 12, 2001 23:19:09 GMT -5
Post by Majin_Blues on Dec 12, 2001 23:19:09 GMT -5
i see how the vh disappears... (as seen in my edit)
but why does it refer to the last number it was before? i thought java "forgets" what an object refers to when you re-assign it
|
|
|
Objects
Dec 12, 2001 23:20:34 GMT -5
Post by Majin_Blues on Dec 12, 2001 23:20:34 GMT -5
does anyone else find the past exams extremely hard like we're all gonna get killed on this final? you should try the december 2000 exam... seemed nice... sort of
|
|
|
Objects
Dec 12, 2001 23:21:25 GMT -5
Post by Sylph on Dec 12, 2001 23:21:25 GMT -5
Here's what I think... since someone tried this and got 20 as the second output... When you make ValHold vh = new ValHold() ; and have v = vh; You're pointing v to vh basically for the reference address. After the another method, vh no longer exists, thus the pointer to vh is removed, and v goes back to the last state it was set as, which is v.i = 20. Make any sense? okok! that's cool! basically ur saying the same thing! yay! a resolution!
|
|