Our Recommendation for You Search your Query, You can find easily. for example search by book name or course name or any other which is related to your education


16 : Passing Object to a function --Java Programming in Urdu

Passing Object to a function

First let's get the terminology straight. The terms "arguments" and "parameters" are used interchangeably; they mean the same thing. We use the term formal parameters to refer to the parameters in the definition of the method. In the example that follows, x and y are the formal parameters.
We use the term actual parameters to refer to the variables we use in the method call. In the following example, length and width are actual parameters.
// Method definition
    public int mult(int x, int y)
       return x * y;

    // Where the method mult is used
    int length = 10;
    int width = 5;
    int area = mult(length, width);
Passing Primitive Types
When any variables of these data types are passed as parameters to a method, their values will not change. Consider the following example:
  public static void tryPrimitives(int i, double f, char c, boolean test)
    i += 10;    //This is legal, but the new values
    c = 'z';    //won't be seen outside tryPrimitives.
      test = false;
      test = true;
}Passing Object References: We can manipulate the object in any way except we cannot make the reference refer to a different object. Suppose we have defined the following class:
class Record
  int num;
  String name;