Explain pass by reference and pass by value?

Answer Posted / ganesh nagalingam

***In Java, primitives and object references are passed by
value.***
The variable represents the bit information which is copied
to the parameter.

eg:primitive****
Say for primitives x=2, the value of 2 is represented in
bits and it is copied to the parameter variable.

eg:object reference***
Button b = new Button("hello");
Button c = b;
Similarly for object reference the bit value in the
reference is copied to the parameter reference. Thus both
references have the same value representing an object. The
object reference(bit representation) represents a way to
get to the object.

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an inner class in java?

529


Is string serializable in java?

549


How are java objects passed to a method and what are native methods?

602


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread

602


What is the difference between class & object?

558






What is the main function in java?

533


What are scriptlets?

601


Explain the difference between call by refrence and call by value?

568


What is the difference between JDBC 1.0 and JDBC 2.0?

2716


How to convert string to char and vice versa?

520


how we can create packages in java?

523


When object is created and destroyed?

642


What happens if I remove static from main method?

531


What are loops in java?

555


Can you make a constructor final in Java?

630