answersLogoWhite

0

pass by value is the technique where a copy of the variable is passed to the method as argument. This value can be modified inside the method but that would not affect the original value.

Pass by reference is the technique where the reference to the actual variable is passed to the method as argument. Any changes to this variable would affect and alter the original value.

Usually primitive data types are passed by value and objects are passed by reference in java.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What are the differences between C and Java reference variables?

Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.


What are the different parameter passing methods used by c plus plus?

Pass by value, constant value, reference and constant reference. Pass by value is the default in C++ (pass by reference is the default in Java).


Does java support call by reference?

No , Java does not support call by reference.


Difference between reference variable and instance variable?

An object is the actual storage space in memory in which some collection of data resides.A reference variable is a variable which refers to the memory location of an object.Look at the pseudocode below:Object obj = new Object();Here obj is the reference variable, and the data to which it refers is the object.


What is the difference between reference and hashcode?

There is no relation between reference and hascode, Java reference is unique pointer which refers an object. so each object will have a unique reference. but 2 diff object can have same hashcode.


How does java pass primitive types and objects?

Java uses only pass by value. Primitive data types are passed purely as pass by value whereas for objects a value which is the reference to the object is passed. Hence the whole object is not passed but its reference gets passed. All modifications to the object in the method would modify the object in the Heap.


Which is the best Book to understand JAVA in short?

You can use Head First Java or Java Complete Reference to learn Java.


Difference between reference and object in java?

On the lower level of Java, a "reference" can be thought of like a pointer in C. It is essentially an integer which refers to (points to) a location in memory where the object data exists. // "button" is a reference to a JButton with a "1" on it (the object). JButton button = new JButton("1");


What is the best book of java language?

the best book of java is java complete Reference 2nd edition.


What is byvalue for java keywords?

There is no such keyword in Java. In general: whether an argument is passed by value or by reference is determined by whether the argument is a primitive (by value) or an Object (by reference). In reality, it's a little more complicated. It seems to be that the actual reference you send as an argument will not change, but the data it refers to will. // This method will not cause a change in the original value. void changeArg(int[] ints) { ints = null; } // This method will. void changeArg(int[] ints) { ints[0] = 0; }


Does passing static strings as parameters to a method create a copy of the String or passes its reference?

Java always follows a pass by value approach.


Difference between equals equals and equal in java?

"==" in java is the binary operator which compares two values and gives a boolean result While "=" in java is a assignment operator which assigns a value to a variable.