Chapter 9 Flashcards

1
Q

what is a method

A

a module that contains a series of statements to carry out a task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are 3 things you can do with a module

A
  • 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are the parts of a method

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are local/global variables

A

local - declared in a method
global - known to all program modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

when you call a method from a program, what 4 things must you know?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are arguments

A

pass a data item into a method from a calling program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are parameters

A

how the method receives the data item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

when a method receives a parameter, you must provide a parameter list that includes

A

the type of the parameter

the local name for the parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a signature

A

the method’s name and parameter list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is passed by value

A

a copy of a value is sent to the method and stored in a new memory location accessible to the method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

each time a method executes, parameter variables listed in the method header are ____

A

redeclared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

to create a method with multiple parameters,

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are sent arguments called

A

actual parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what are variables that accept the parameters in the method called

A

formal parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does going out of scope means

A

a variable declared within a method ceases to exist when the method ends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

to retain a value that exists when a method ends, what do you have to do

A

return the value from the method back to the calling method

17
Q

when a method returns a value, the method must have a __

A

return type that matches the data type of the value that is returned

18
Q

what does a return type (AKA method type) for a method do

A

indicates the data type of the value that the method will send back

19
Q

what do you do when you want a method to return nothing

A

return type void

EX: Void method

20
Q

although you are allowed to include multiple return statements in a method, its not recommended. Why?

A

because it violates structured logic ( there is only supposed to be one way in and one way out)

21
Q

what is overhead

A

the extra resources and time required by an operation

22
Q

how do you pass a single array element to a method

A

the same method to pass a variable to a method

23
Q

how do you pass an entire array as an argument

A

indicate that the method parameter must be in a array (put square brackets after data type)

the arrays are then passed by reference (the method receives the actual memory address of the array and has access to it)

24
Q

what is overloading a method

A

several methods that have the same name but are doing different tasks

25
Q

what is polymorphism

A

the ability of a method to act appropriately according to the context

26
Q

what is an ambiguous methods

A

situations in which the compiler cannot determine which method to use