Quiz 11 Flashcards

(10 cards)

1
Q

Which of the following best describes a block in programming?
A runtime error caused by invalid memory access; A method for iterating over collections; A set of statements enclosed in {} that defines a scope; A type of conditional statement

A

A set of statements enclosed in {} that defines a scope

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

What is “scope” in a programming language?
The place where the variable is stored; The region in a program where a variable can be accessed; The data type of a variable; The lifetime of a variable

A

The region in a program where a variable can be accessed

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

What is a key disadvantage of dynamic scoping?
It results in slower program execution; It forces variables to be global; It uses more memory during runtime; It makes code harder to debug due to less predictable variable resolution

A

It makes code harder to debug due to less predictable variable resolution

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

What is the primary purpose of a symbol table in a compiler?
To store information about identifiers
To keep track of syntax rules
To store program code
To generate machine code

A

To store information about identifiers

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

What is “semantics” in programming languages?
The syntax rules of a language
The use of data structures
How programs are compiled
The study of meaning in programming constructs

A

The study of meaning in programming constructs

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

Which of the following is NOT a method for specifying semantics?
Defining a translator
Syntax tree compression
Language reference manual
Formal definition

A

Syntax tree compression

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

If binding time is _____, it is considered as dynamic binding.
Execution time
Link time
Translation time
Language definition time

A

Execution time

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

Which of the following syntax errors cannot be detected using a symbol table?
Duplicate declaration of variables
Misplaced semicolons
Type mismatches in assignments
Use of undeclared variables

A

Misplaced semicolons

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

What is binding in programming languages?
The process of debugging a program
The process of resolving a method call at runtime
The process of converting source code into machine code
The process of associating an attribute with a name

A

The process of associating an attribute with a name

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

When analyzing nested scopes, why is a stack an appropriate data structure?
Because it maintains a LIFO order, aligning with how nested scopes are entered and exited
Because it supports bidirectional traversal
Because it provides constant time-access to all variables
Because it allows elements to be accessed randomly

A

Because it maintains a LIFO order, aligning with how nested scopes are entered and exited

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