12 - Variable Attributes and Bindings Flashcards

(31 cards)

1
Q

variable attributes (6)

A
  1. name
  2. address
  3. type
  4. value
  5. lifetime
  6. scope
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

identifier of the variable

A

name

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

true or false:

variables must always have names

A

false, variables can be temporary or anonymous objects that don’t have a name

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

the memory location associated with the variable at current time

A

address

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

true or false:

when recursion is employed, the same local variable name can have multiple address during execution

A

true

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

it happens when two or more identifiers refer to the same address

A

aliases

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

in this code snippet, what is b?

int a = 5;
int *b = &a;
A

b is an alias of a

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

what will be the result of the code snippet below:

int a = 5;

int *b = &a;

*b = 9;

printf("a = %d, *b = %d\n", a, *b);
A

a = 9; *b = 9

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

the set of values valid for a specific variable is defined by this attribute

A

type

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

the operations that are legal/defined are set by this attribute

A

type

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

sometimes, the size/format of the variable is defined/set by this attribute

A

type

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

the bits stored in memory cells

A

value

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

the memory is also modeled as __

A

abstract cells

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

refers to the location you need to write

A

L-value

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

refers to the data contents you read

A

R-value

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

in the code snippet below, what does x and y+1 refer to?

x = y+1;
A

x: x’s L-value
y+1: x’s R-value

17
Q

refers to the activation to deactivation

18
Q

the time during which the variable is bound to a specific memory location

19
Q

step-by-step process of how lifetime works (5)

A
  1. allocate memory for variable
  2. bound memory cell/s to variable
  3. use variables
  4. unbound memory cell/s
  5. deallocate memory of the variable
20
Q

the region of a program’s source code where a particular variable/name is visible and can be accessed

21
Q

what type of scope does int a = 5; have?

int a = 5;

int main() {
    int a = 2;
    {
        int a = 3;
     }
}
22
Q

what type of scope does int a = 2; have?

int a = 5;

int main() {
    int a = 2;
    {
        int a = 3;
     }
}
23
Q

what type of scope does int a = 3; have?

int a = 5;

int main() {
    int a = 2;
    {
        int a = 3;
     }
}
24
Q

association between an attribute and entity

25
__ = when that association is fixed
binding time
26
understanding __ is a prerequisite to understanding the semantics of the programming language
binding time
27
type bindings (2)
1. static binding 2. dynamic binding
28
occurs before run time and remains unchanged throughout the program execution
static binding
29
occurs during runtime and can change in the course of the program execution
dynamic binding
30
what kind of type binding does java exhibit?
static binding
31
what kind of type binding does python exhibit?
dynamic binding