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 |
What are predefined functions?
Difference between method overloading and overriding.
What is the method overriding?
What are the basics of core java?
What is java object name?
when we write class.forName("any one class"); what happens actually?what it will return?explain stepwise?
If a multi threaded Java program has started numerous number of threads, at any point in time how to know which thread is currently executing/running ?
7 Answers Accenture, College School Exams Tests, iFlex, NIIT,
Does java have extension methods?
What is vector?
How big is a 64 bit float?
how can be object class inherited to all class in a program when java does not support multiple inheritance??
How does a cookie work in Servlets?