Java support call by reference (pass by reference) ?



Java support call by reference (pass by reference) ?..

Answer / sarju001

yes java support call by reference only using StringBuffer
class.

Here, is an example of call by reference

public class PassByReference
{
public static void passref(StringBuffer s)
{
s = s.insert(8, "j2ee & ");
System.out.println(s);
}
public static void main(String[] args)
{
StringBuffer str = new StringBuffer("Welcome java
program");

System.out.println(str);

passref(str);

System.out.println(str);
}
}


output :-

Welcome java program
Welcome j2ee & java program
Welcome j2ee & java program

Is This Answer Correct ?    9 Yes 0 No

Post New Answer

More Core Java Interview Questions

can abstract class have constructor how can you achive this ?

4 Answers   Fidelity,


What is CardLayout?

1 Answers   Infosys,


Is it safe to install java on my computer?

0 Answers  


Is it compulsory for a try block to be followed by a catch block in java for exception handling?

0 Answers  


why we import both packages java.awt.*; and java.awt.event.*; as java.awt.*; can import all classes na. then what is the need of importing java.awt.event.*; ?

3 Answers  






What is java lang object?

0 Answers  


Why string is not a wrapper class?

0 Answers  


What is array length?

0 Answers  


Can inner class final?

0 Answers  


What is function and method in java?

0 Answers  


What is an infinite loop?

0 Answers  


What is the length of a string?

0 Answers  


Categories