Chapter 9 Flashcards
what is a method
a module that contains a series of statements to carry out a task
what are 3 things you can do with a module
- invoke or call a method from another program/method
-any programs can contain an unlimited number of methods and a method can be called an unlimited number of times
-calling a program/method is called the method’s client
what are the parts of a method
method header - name/declaration/definition of method
method body - contains implementation (statements that carry out the tasks)
method return statement - returns to the calling method
what are local/global variables
local - declared in a method
global - known to all program modules
when you call a method from a program, what 4 things must you know?
what the method does
name of the method
type of info to sent to the method
type of return data to expect from the method
what are arguments
pass a data item into a method from a calling program
what are parameters
how the method receives the data item
when a method receives a parameter, you must provide a parameter list that includes
the type of the parameter
the local name for the parameter
what is a signature
the method’s name and parameter list
what is passed by value
a copy of a value is sent to the method and stored in a new memory location accessible to the method
each time a method executes, parameter variables listed in the method header are ____
redeclared
to create a method with multiple parameters,
separate the arguments by a comma within a method call
list the data type and local identifier for each parameter within method header’s parentheses, separating each parameter with a comma
what are sent arguments called
actual parameters
what are variables that accept the parameters in the method called
formal parameters
what does going out of scope means
a variable declared within a method ceases to exist when the method ends