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]]
void Func2[int& x, double& y] { x = 12; // these WILL affect the original arguments y = 20.5; }
int num; double avg; Func2[num, avg]; // legal Func2[4, 10.6]; // NOT legal Func2[num + 6, avg - 10.6]; // NOT legal
int Task1[int x, double y]; // uses return by value int& Task2[int x, double y]; // uses return by referenceThis 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 _____ ___ ____.