jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why does value not change??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why does value not change???" Watch "why does value not change???" New topic

why does value not change???

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
What is the output of this program ?

Choose: 1


1.) FunnyMan

2.) seizure

3.) mothulla

4.) NullPointerException

5.) Compile time error

answer is seizure..i expected it to be mothulla...since the set method calls setname method and sets it value to mothulla....
if anybody has understood kindly explain..thanks in advance
Lokesh Varma

Joined: Dec 30, 2009
Posts: 3
void deleteSharpen(Sharpen sharpen)
sharpen = null;
sharpen = new Sharpen();

In the above function the argument "sharpen" is local to method. It is shadowing the instance variable "sharpen". You are making local variable to NULL. change the argument to any other name as shown below:

void deleteSharpen(Sharpen sharpen1).....you will get output "mothulla"
I agree. Here's the link: http://aspose.com/file-tools
subject: why does value not change???
jQuery in Action, 3rd edition