Lecture 4 Flashcards

1
Q

What are variables in programming?

A

Variables are abstractions in a language for the memory cells of a machine.

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

What are the main attributes of a variable?

A

Type, Scope, Lifetime.

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

What are names associated with in programming?

A

Names are associated with subprograms, formal parameters, and other program constructs.

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

What is an Identifier?

A

Identifier is another term for a name.

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

What are some design issues for names?

A

Whether names are case sensitive and whether special words are reserved words or keywords.

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

What are the forms of names(name forms) in programming languages?

A

Names are strings of characters used to identify entities in a program, with different length limitations and naming conventions depending on the language.

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

What are common naming conventions?

A

Underscore characters and Camel notation.

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

What is the controversy around case sensitivity in programming languages?

A

Some believe it detracts from readability, while others do not see it as a problem.

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

What are special words in programming languages used for?

A

To make programs more readable and to separate syntactic parts of statements and programs.

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

What is the difference between a keyword and a reserved word?

A

A keyword is special only in certain contexts, while a reserved word cannot be used as a name.

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

What attributes characterize a variable?

A

Name, address, type, lifetime, and scope.

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

What is the address of a variable?

A

The machine memory address associated with the variable.

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

What are aliases?

A

When more than one variable name can access the same memory location.

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

What does the type of a variable determine?

A

The type determines the set of values the variable can store and the operations that can be performed on those values.

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

What is the value of a variable?

A

The contents of the memory cell(s) associated with the variable.

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

What is binding in programming?

A

The association between an attribute and an entity.

17
Q

When can binding occur?

A

Language design time, implementation time, compile time, load time, link time, and run time.

18
Q

What is static binding?

A

Binding that occurs before run time and remains unchanged during program execution.

19
Q

What is dynamic binding?

A

Binding that occurs during run time or can change during program execution.

20
Q

What must happen before a variable can be referenced in a program?

A

It must be bound to a data type.

21
Q

What are explicit and implicit declarations in static type binding?

A

Explicit declaration specifies variable names and types; implicit declaration uses default conventions to associate variables with types.

22
Q

What is dynamic type binding?

A

The type of a variable is bound when it is assigned a value in an assignment statement.

23
Q

What is an advantage of dynamic type binding?

A

Provides more programming flexibility.

24
Q

What is a disadvantage of dynamic type binding?

A

It diminishes the error-detection capability of the compiler and requires run-time type checking.

25
Q

What is allocation in the context of storage bindings?

A

The process of taking memory cells from a pool of available memory.

26
Q

What is deallocation?

A

Returning a memory cell to the pool of available memory after it is unbound from a variable.

27
Q

What is the lifetime of a variable?

A

The time during which a variable is bound to a specific memory location.

28
Q

What are static variables?

A

Variables bound to memory cells before program execution begins and remain bound until program termination.

29
Q

What are stack-dynamic variables?

A

Variables whose storage bindings are created when their declaration statements are elaborated during run time.

30
Q

What is an advantage of implicit heap-dynamic variables?

A

High flexibility and the ability to write highly generic code.

30
Q

What are explicit heap-dynamic variables?

A

Nameless memory cells allocated and deallocated by explicit run-time instructions, referenced through pointers or reference variables.

31
Q

What are implicit heap-dynamic variables?

A

Variables bound to heap storage only when assigned values, with all attributes bound at each assignment.

32
Q

What is a disadvantage of implicit heap-dynamic variables?

A

Run-time overhead for maintaining dynamic attributes and loss of some compiler error detection.

33
Q

In what way are reserved words better than keywords?

A

Compile time, load time, link time, and run time.

34
Q

Define binding and binding time.

A

Binding is the association between an attribute and an entity, and binding time is when this association occurs.