Chapter 9 Flashcards

1
Q

a program module that contains a series of statements that carry out a task.

A

Method

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

contains the method’s implementation

A

method body

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

This contains identifying information about the method

A

Method header

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

Global is the opposite of

A

local scope / in scope

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

True or False: When a variable is declared locally within a method, its value cannot be used by other methods.

A

True

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

The calling program or method is the method’s…

A

client

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

The statements that carry out a task.

A

Implementation

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

A called method accepts the values it receives from the calling method; these accepted values are the called’s methods _________.

A

parameters

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

When a program passes a data item to a method, the data item is an __________ to the method

A

argument (to the method).

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

When writing the declaration for a method that can receive a parameter, you must provide a ________ ____.

A

parameter list

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

What are the two items that make up a parameter list?

A
  1. Parameter type

2. Local name for the parameter

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

The two elements of the parameter list, combined, make up the _______ _________.

A

method’s signature

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

A variable passed into a method is _______ ___ ______, which means that A COPY of its value is sent to the receiving method and stored in a new memory location accessible to that method.

A

passed by value

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

Because of the passed by value functionality, any value that aligns with the preordained _________ ____ can be passed to a method, even if this value is variable, a named constant, or an arithmetic expression, etc.

A

parameter type

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

True or False: When the method ends at the return statement, the locally declared parameter variables cease to exist.

A

True

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

The starting value of the main program occupies a different _______ _______ from the variable in the local program/module/method.

A

memory address

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

This gives back control to the calling method after a modular method executes.

A

method return statement

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

The arguments sent to a method in a method call

A

Actual parameters

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

The variables in the (receiving) method’s declaration

A

Formal parameters

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

When a method returns a value, the method must have a ______ ____ that matches the data type of the returned value.

A

return type

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

What is it called when a method returns nothing at all?

A

void method

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

This is listed in front of the method name when the method is defined.

A

Method’s (return) type

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

True or False: A method’s return type is a part of the method’s signature.

A

False

24
Q

The method’s signature consists of….

A

the method name and its parameter list

25
Q

A method’s return statement can return how many values, at most?

A

ONE. This is why Objects come in handy.

26
Q

What are the two ways of retaining a method’s return value?

A
  1. Storing it in a variable in scope to the mainline logic/calling method
  2. Placing it in an output statement
27
Q

True or False: You can use a method as a variable in an arithmetic function, so that its value is retrieved and calculated at the same time.

A

True

28
Q

If a program needs to use a method’s return value in more than one place, storing the returned value in a variable decreases _______.

A

overhead

29
Q

A tool that identifies and categorizes each item needed within the method as pertaining to the input, processing or output

A

IPO chart

30
Q

True or False: A method’s return type must match at least one of the method’s parameters.

A

False

31
Q

This describes how arrays are used in a method

A

Passed by reference

32
Q

True or False: When an array is passed by reference, the method receives the actual memory address of the array and has access to the actual values in the array elements.

A

True

33
Q

True or False: When you pass an array to a method, changes you make to the array elements within the method are reflected in the original array that was sent to the method; in other words, the data residing in the original memory address is overwritten.

A

True

34
Q

True or False: You indicate that method parameter must be an array by placing parentheses after the data type in the method’s parameter list.

A

False, you place SQUARE BRACKETS, not parentheses.

35
Q

Supplying diverse meanings for a single identifier

A

Overloading (the method)

36
Q

Any extra time and resources required by an operation

A

Overhead

37
Q

Overloading a method is an example of __________.

A

polymorphism

38
Q

A situation in which the compiler cannot determine which method to use; this is a risk, and antithesis, of overloading .

A

Ambiguous methods

39
Q

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

A

Polymorphism

40
Q

Overloading a method occurs when multiple methods have the same name, but different ________ ______.

A

parameter lists

41
Q

What are the 3 rules of method design?

A
  1. Employ implementation hiding
  2. Increase cohesion
  3. Reduce coupling
42
Q
The four details of a predefined method:
1. What the method does in general
2. The method's name
3.
4.
A
  1. The method’s required parameters/data types.

4. The method’s return type

43
Q

The “interface to the method” is….

A

the only part of a method with which the method’s client interacts

44
Q

When it comes to a _____ ___, you can examine what goes in and what comes out, but not the details of how the method works inside.

A

black box

45
Q

How the internal statements of a method serve to accomplish the method’s purpose

A

Cohesion

46
Q

Implementation hiding is based on the __________ of method details.

A

encapsulation

47
Q

When all of a method’s operations contribute to the performance of a single task.

A

Functional cohesion

48
Q

Coupling is a measure of the strength of the ________ between two program methods; it expresses the extent to which information is exchanged by methods.

A

connection

49
Q

True or False: The best methods pass single arguments rather than many variables/records

A

True

50
Q

This occurs when a method is defined in terms of itself.

A

Recursion / recursive method

51
Q

Whenever a method is called, the address to which the program should return, upon the method’s completion, is stored in a memory location called the _____.

A

stack

52
Q

This is the result of too many return addresses.

A

Stack overflow

53
Q

This is the input value that makes the recursion stop.

A

Base case

54
Q

This is the input values that cause a method to recur.

A

Recursive case

55
Q

What are some the drawbacks of tight coupling?

A
  1. Many data paths to keep track of
  2. Many chances for bad data to pass from one method to another.
  3. Many chances for one method to alter information needed by another method.
56
Q

True or False: Many globally defined variables increase the chances of tight coupling.

A

True, because when one method changes the valued stored in a variable, other methods are affected.

57
Q

What is another phrase for the base case?

A

Terminating case