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 the map interface in java programming?

583


what do you mean by classloader?

549


Why string is not thread safe?

536


Is empty list java?

519


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?

585






Explain tree set and its features?

597


Define inheritance?

549


What does %d do in java?

578


What is proper subset?

535


what is the significance of listiterator in java?

616


Is string an object?

649


What is the difference between static (class) method and instance method?

568


Can you instantiate the math class in Java?

605


why an outer class cannot be declared as private?

3612


What is abstraction in java?

613