Java Important concepts

1. Is Java Pass by Value or Pass by reference

Ans:= Java is always "Pass By Value". Car car is not a Car object but a pointer to a Car object. What happens when you do this
changeColor(car)
Here we are passing the address of the created Car object into the method. You can assign a pointer, pass the pointer to a method, follow the pointer in the method and change the data that was pointed to. However, you cannot change where that pointer points.


No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days