GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 41 of 502    Print  
When you have an object passed to a method and when the object is reassigned to a different one, then is the original reference lost

  
Total Answers and Comments: 5 Last Update: June 09, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Ashutosh Gupta
 
No Reference is not lost. Java always passes the object by reference, now two references is pointing to the same object.

Above answer was rated as good by the following members:
vartikas
June 26, 2005 07:14:41   #1  
Ashutosh Gupta        

RE: When you have an object passed to a method and when the object is reassigned to a different one, th...
No Reference is not lost. Java always passes the object by reference now two references is pointing to the same object.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
October 11, 2005 11:24:48   #2  
Bill Leonard        

RE: When you have an object passed to a method and wh...
In Java it is ALWAYS pass by VALUE. Confusion occurs because all OBJECT variables in Java are references to objects. When we call a method in Java the object reference is PASSED BY VALUE to the method (this means that a variable for the method's argument is created and the reference is COPIED to it).
 
Is this answer useful? Yes | No
August 14, 2007 09:28:57   #3  
pallavi        

RE: When you have an object passed to a method and wh...
Yes we can create more copy of object.
 
Is this answer useful? Yes | No
September 17, 2007 01:02:14   #4  
Amit Patil        

RE: When you have an object passed to a method and wh...

@Bill:Pass by value of objects references is called pass by reference. In java its always pass by references unless we are dealing with primitives which is pass by value.

If a object is reassigned to a new refernces the original reference is not lost


 
Is this answer useful? Yes | No
June 09, 2008 11:36:34   #5  
vinaymudgil007 Member Since: May 2008   Contribution: 43    

RE: When you have an object passed to a method and when the object is reassigned to a different one, then is the original reference lost
No the orignal refererence is still intact....... this is because even though it's a fererence but java still pass it by value

vinny

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape