Computational Constructs Flashcards

1
Q

How is code modularity improved?

A

Keeping sub-programs as self contained as possible so they can be tested independently

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

What is the scope of a variable?

A

the part / parts of the program where a variable can be used - eg local variables only exist within the sub program they are defined inside

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

Why are global variables best avoided when possible?

A

They have global scope so can be accessed anywhere throughout the program. So their values can be altered unintentionally to bad effect

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

What are sub-programs defined and called with?

A

Defined with formal parameters

Called with actual parameters

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

What is a computational construct?

A

A combination of control structures which can be used to make solving programming programs more intuitive

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

The scope of a variable describes…

A

Where it can be accessed from

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

What is meant by variable declaration?

A

When a variable is created in a program

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

What is a user defined function?

A

A sub-program written by the programmer which returns a value

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

What is a method in an object-oriented language?

A

A function which is defined inside a class and can only be used in relation to an object of that class

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

Parameters can be passed by….name and define both terms

A

Value: Parameters which are not changed when passed into a procedure (a local copy of the actual parameter is made and used inside the subroutine)
Reference: Parameters which may be changed by the procedure they are passed into

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

What is unique about a sequential file compared to other input and output devices?

A

Treated in the same way but they have specific commands for opening and closing

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

Function use

A

A category of sub program which will always return a single value to another part of the program

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

Scope of a local variable

A

The sub program where it has been created

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

Where are actual parameters listed?

A

On the call line used to activate a sub program

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

Why is it unnecessary to use the same identifier (name) for related actual and formal parameters?

A

Most software development environments link parameters based on the order in which they are listed rather than their names
Allows for procedures/functions to be called several times with different values being passed in on each occasion

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

How is an array usually passed and why?

A

By reference because passing an array by value would create too many copies which would place a large demand on RAM

17
Q

Pre-Defined Function

A

Already defined by the high level language, examples:random, round

18
Q

Call

A

Executes a sub-program from another part of a larger program

19
Q

What is necessary when listing formal parameters in the declaration/definition of a sub program?

A

The data type so that the sub-program can expect a type of data for the parameter to use

20
Q

Data Flow

A

The way in which data flows from one part of the program into another, e.g. from the main program into / back from a subroutine