Name and explain the types of ways which are used to pass arguments in any function in java.

devquora
devquora

Posted On: Jun 25, 2024

 

In Java, there are basically two ways by which arguments can be passed in any function. They are: –

  • Pass by value- in this, a copy of the value of the arguments is passed in the function. If any changes are made to the parameters of the sub-routine, then there is no effect on the arguments which are used to call it.
  • Pass by reference- In this, the copy of the address of the parameters are passed in the function and if any changes are made to the parameters, then it will have an effect on the arguments used to call the sub-routine.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Core Java Interview Questions

    Explain the significance of class loaders in Bootstrap?

    Classloaders in Java load classes into the virtual environment, converting named classes into binary form. They load essential classes, such as java.lang.Object, on demand. Java Runtime Environment in..

    Core Java Interview Questions

    What is the difference between JDK, JRE, and JVM?

    JVM (Java Virtual Machine) executes Java bytecode, providing a runtime environment. JRE (Java Runtime Environment) includes JVM and necessary libraries. JDK (Java Development Kit) contains JRE and dev..

    Core Java Interview Questions

    What are the various access specifiers in Java?

    Access specifiers in Java determine the access scope of classes, methods, and fields. They include public (accessible from anywhere), protected (accessible within the same package and subclasses), def..