adspace


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 difference between equals() and == in java?

1050


What is a classloader in java?

1101


Differentiate between static and non-static methods in java.

1135


Realized?

2278


What is java string pool?

1091


What is the difference between break and continue statements?

1135


What do you mean by an interface in java?

1110


What is an object in java and how is it created?

1153


How to sort array in descending order in java?

1005


What are the differences between heap and stack memory in java?

1152


Explain public static void main(string args[]) in java.

1089


explain different ways of using thread? : Java thread

1092


Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example

2677


Write a program to find the whether a number is an Armstrong number or not?

1110


What is a constructor overloading in java?

1136