the object created at line 1 shud be garbage collected after the call of makeThisNull in main as m is pass by reference so assigning pm to null will reflect m . but the answer given by enthuware tests is that its not garbage collected till the end of the program
// class test
Now coming to your question, if two variables are pointing to the same thing and one of them then starts pointing to something else, should it change what the other variable was pointing to also?
Here is a post that might interest you. That should answer your first question.
Ok, so before we take your second question, let's just get a confirmation from you that you understand the answer of the first one.
[ Edit : Ninja'd ]
* Notes: Java is pass by value always. Pass-by-value means that when you call a method, a copy of the value of each actual parameter is passed to the method. You can change that
* copy inside the method, but this will have no effect on the calling method.
* If the variable you are passing in is of reference type and you change the properties of the referred
* to object without pointing the reference to a new object then your changes will be visible in the calling method. The reference was still passed by value.