Data values passed to a method when it is called are known as __________.

  • In this version of the example, the Twice function looks like this:
      void Twice(int& a, int& b)
      {
        a *= 2;
        b *= 2;
      }
    
    • Note that when it is run, the variables passed into Twice from the main() function DO get changed by the function
    • The parameters a and b are still local to the function, but they are reference variables (i.e. nicknames to the original variables passed in (x and y))

  • When reference variables are used as formal parameters, this is known as Pass By Reference
      void Func2(int& x, double& y)
      {
        x = 12;		// these WILL affect the original arguments
        y = 20.5;
      }
    
  • When a function expects strict reference types in the parameter list, an L-value (i.e. a variable, or storage location) must be passed in
      int num;
      double avg;
      Func2(num, avg);		// legal
      Func2(4, 10.6);		// NOT legal
      Func2(num + 6, avg - 10.6);	// NOT legal
    
  • Note: This also works the same for return types. A return by value means a copy will be made. A reference return type sends back a reference to the original.
      int Task1(int x, double y);	// uses return by value
      int& Task2(int x, double y);  // uses return by reference
    
    This is a trickier situation than reference parameters (which we will not see in detail right now).
  • A class may be thought of as an apple pie; while the baking (or creation of the object) is called ______________.

  • A class is formally called a ___________ for creating objects.

  • A METHOD is a small program that has a _________, _________, a _________ (process), and possibly returns (gives back) __________.

    • name
    • variables
    • body
    • parameters

  • Those METHODS that DO NOT return a parameter have the word __________ in their first line (header).

  • A _________ is a collection of statements that are grouped together to perform a function or procedure.

  • We ________ or "call a method" when we want ito to perform/execute.

  • _________ __________ is the combination of the method name and the parameter list; this this compose the "method header".

  • The variables defined in the method header are known as ________ _________.

  • When a method is invoked, you _______ _ ______ to the parameter. This passed value is referred to as an ________ _________ or ___________.

    • pass a value
    • actual parameter
    • argument

  • The _____________ is the data type of the value the method returns.

  • If the method does not return a value, the returnValueType is the keyword _________.

  • A ________ statement is required for a value-returning method.

  • Stacks are areas in _______ _________.

  • When you invoke the method using:
    nPrintln("Welcome to Java", 3);
    what is the output?

    • Welcome to Java
    • Welcome to Java
    • Welcome to Java

  • ____________ involves supplying different meanings for a single identifier.

  • ________ a _______ means writing multiple methods with the same name but different parameter lists.

  • When we call an overloaded method , the IDE understands which version of the method to use based on the _______ _______ used.

  • True or False?
    Overloading methods is never required in a program.
    True False

  • The only advantage of overloading methods is provide to your method's ________.

  • Instead of overloading a method, you could instead create multiple different methods with _______ ________.

  • ___________ methods are situations in which the compiler cannot determine which method to use.

  • Every time you call a method, the Java IDE compiler decides whether a suitable method exists.
    If so the method _________.
    If not, you receive an ________ _______.

  • A ________ variable is a variable defined within a method.

  • ________ is the part of the program where the variable can be referenced (identified and used).

  • A local variable must be _______  before it can be used.

  • A local variable cannot be used ________ of the method where it was defined.

  • The scope of a local variable starts from its ____________ and continues to the _____ ___
    ______ _____.

    • declaration
    • end of the block

  • Each time you correctly declare a variable with the same name, a separate and different _______ _______ is assigned to it.

  • Can you declare a local variable with the same name multiple times in different non-nesting blocks in a method?

  • Can you declare a local variable twice in nested blocks?

    • 1. Write a method once and reuse it anywhere.
    • 2. Information hiding.
    • 3. Reduce complexity.

  • Method _________ is achieved by separating the use of a method from its implementation.

  • When the details of t the implementation are encapsulated in the method and hidden from the client who invokes the method, it is knows as information ________ or _________.

  • The arguments that are passed to a method should have the same _______, ________, and ________ as the parameter in the method signature.

  • The method header specifies the __________, return value type, ______ ______ and _________ of the method.

    • modifiers
    • method name
    • parameters

  • The signature of a method consist of _________ ________ and ________ _______.

    • method name
    • parameter list

  • public static ______ main(String args[])

  • public static void main(_________ ____ ___)

  • Arguments to methods always appear in _________.

  • Each time a method is invoked, the system stores parameters and local variables in an area of memory, known as a ____________.

  • A _____ is a simple but incomplete version of a method.

  • When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as _____ ___ ____.

    What is the name given to a value that is passed into a method?

    Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration's parameters in type and order.

    Are data items sent to methods in a method call?

    Data items sent to methods in a method call. The data items received by a method. A principle of object-oriented programming that describes the encapsulation of method details within a class. The interface to a method includes the method's return type, name, and arguments.

    When an object is passed as an argument to a method?

    When an object is passed as an argument to a method, this is actually passed. this is the name of a reference variable that is always available to an instance method and refers to the object that is calling the method. This array field holds the number of elements that the array has.

    When an object is passed as an argument to a method what is passed into the method's parameter variable?

    When code in a method changes the value of a parameter, it also changes the value of the argument that was passed into the parameter. When an object, such as a String , is passed as an argument, it is actually a reference to the object that is passed. The contents of a String object cannot be changed.