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 is the difference between applet and swing and gui application in java . What we do with the collections set and list interface

2 Answers   CTS, Phoenix Technologies,


Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.

2 Answers   Accenture,


What is a condition in java?

0 Answers  


which one is performance wise advantageious from List,Set,Map?

6 Answers  


what is the use of Clonable,and serializable interface?

1 Answers  


where to use join method and explain with real time senario?and programatical explenation also..

1 Answers   TCS,


Explain the difference between association, aggregation and inheritance relationships.

0 Answers  


Which package is used for pattern matching with regular expressions?

0 Answers  


if two references are having same hash codes,is that means those are refering to same object?

5 Answers   CTS,


Explain different types of wrapper classes in java?

0 Answers  


How does serialization work

3 Answers   Ordain Solutions,


there are some duplicate values in ArrayList, how U'll get that array with out duplicate?

4 Answers   CMC,


Categories