Modules Flashcards

1
Q

What is a module in programming?

A

A group of statements that perform a specific task within a program.

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

What is the purpose of dividing a program into smaller modules?

A

To divide and conquer large tasks, making them manageable.

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

List three benefits of using modules in programming.

A

Simpler code, code reuse, easier maintenance.

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

What is the recommended type of name for a module?

A

Descriptive names using verbs to indicate actions, e.g., calculateGrossPay.

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

What are the two parts of a module definition?

A

A header and a body.

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

Where does a program begin executing?

A

In the main module.

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

What is a return point in module calling?

A

A memory location where the program returns after a module call.

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

What shape is used to represent a module call in a flowchart?

A

A rectangle with vertical bars at each side.

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

What is the goal of top-down design?

A

To break down a task into subtasks and code after identifying them.

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

What does a hierarchy chart represent?

A

The relationships between modules in a program.

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

Where can a local variable be accessed?

A

Only inside the module in which it is declared.

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

What happens if two variables have the same name but are declared in different scopes?

A

They are treated as separate variables.

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

What is the scope of a variable?

A

The part of a program where a variable can be accessed, starting from its declaration to the end of its module.

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

What is an argument in a module?

A

Data passed into a module when it is called.

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

What is the role of a parameter in a module?

A

To store the argument passed into the module.

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

What happens if an argument and a parameter have mismatched data types?

A

An error occurs.

17
Q

What is the scope of a parameter variable?

A

The entire module where it is declared.

18
Q

What is the difference between passing arguments by value and by reference?

A

By value: The parameter gets a copy of the argument, with no effect on the original variable.
By reference: The parameter acts as an alias, allowing changes to affect the original variable.

19
Q

What is a global variable?

A

A variable declared outside of all modules and accessible by all modules.

20
Q

Why should the use of global variables be limited?

A

They can make debugging and understanding the program difficult.

21
Q

What are the benefits of using global constants instead of global variables?

A

Global constants can’t be changed during runtime, reducing hazards associated with global variables.