Programming Flashcards

1
Q

What happens when a variable is declared?

A
  1. The compiler is told the data type for the values being stored (so that it knows how much space to reserve)
  2. The compiler is being told the identifier that you will be using to refer to that space in memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are constants and how do they work?

A

Constants are named references to literal values. When the program is complied, any references to the constants are replaced by actual values in machine code.

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

What are the benefits of using constants?

A
  • The code becomes easier to understand as descriptive labels are used instead of values
  • The code is easier to maintain as a constant’s value can be changed in one place
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a global scope?

A

It can be referred to anywhere in the program

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

What are features of local variables?

A
  • Their value cannot be accessed or modified from outside the subroutine
  • Their identifier can be reused in other subroutines
  • only stored in memory when the subroutine is being executed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a parameter in a subroutine?

A

Part of the subroutine’s interface that allows values to be passed into the subroutine when it is called

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

What is an argument in a subroutine?

A

Value passed to a subroutine via a parameter

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

What is passing by value?

A

A literal value or copy of a data structure is given to the subroutine. A change made to this copy does not have any effect on the original.

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

What is passing by reference?

A

The subroutine is given a pointer to the address of the value/object in memory. If changes are made to the referenced value or data structure, they change the original so the change persists after the subroutine has finished.

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

What is exception handling?

A

Allows programmers to decide how a program should respond to the occurrence of an error that would otherwise lead to the program terminating abruptly.

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