By default, Strings to functions are passed using the method(a) Call by Value (b) Call by Reference (c) Strings cannot be passed to function

(b)

String is a class defined in java.lang and in java all classes are passed by reference.

Showing Answers 1 - 2 of 2 Answers

Hari

  • May 9th, 2005
 

By default all primitives and Strings are passed by Value only

  Was this answer useful?  Yes

Manish Mishra

  • Jul 6th, 2005
 

Wrong answer 
 
In Java everything. I mean EVERYTHING is pass by value. References are PASSED BY VALUE. And for god's sake it has got nothing do with java.lang. 
 
try this 
 
public void someMethod(){ 
Vector someVector = new Vector(); 
someOtherMethod(someVector); 
System.out.println(someVector.toString()); 

 
public void someOtherMethod(Vector someVector){ 
Vector anotherVector = new Vector(); 
anotherVector.add("Hello"); 
someVector = anotherVector; 

 
run the above and draw little boxes and u will get it.  
 
 
 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions