4 ms·
You got it backwards. The Java snippet will print "Lassie". In Java, object names are references to objects, and passing them to functions copies the references
by E6300 9y ago
You got it backwards. The Java snippet will print "Lassie". In Java, object names are references to objects, and passing them to functions copies the references, so of course modifying the formal parameter (d from replaceDogWithToby()) doesn't modify the actual parameter (d from main()).