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

What about anonymous inner classes in java?

0 Answers  


What is jvm? Why is java called the platform independent programming language?

0 Answers  


What is lexicographically smallest string?

0 Answers  


When does a class need a virtual destructor?

0 Answers   Flextronics,


How do you print array in java?

0 Answers  






What is break and continue statement?

0 Answers  


How do you escape in java?

0 Answers  


Java support call by reference (pass by reference) ?

1 Answers   HCL,


What is the difference between actual and formal parameters?

0 Answers  


State the main difference between c++ and java?

0 Answers  


Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?

2 Answers  


How does a cookie work in Servlets?

0 Answers  


Categories