Quiz 11 Flashcards

(10 cards)

1
Q

What is “semantics” in programming languages?

The use of data structures
The syntax rules of a language
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
2
Q

Which of the following syntax errors cannot be detected using a symbol table?

Use of undeclared variables
Type mismatches in assignments
Misplaced semicolons
Duplicate declaration of variables

A

Misplaced semicolons

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

Which of the following is NOT a method for specifying semantics?

Syntax tree compression
Formal definition
Language reference manual
Defining a translator

A

Syntax tree compression

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

What is binding in programming languages?

The process of converting source code into machine code
The process of associating an attribute with a name
The process of debugging a program
The process of resolving a method call at runtime

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
5
Q

Which of the following best describes a block in programming?

A runtime error caused by invalid memory access.
A set of statements enclosed in {} that defines a scope.
A type of conditional statement.
A method for iterating over collections.

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
6
Q

What is a key disadvantage of dynamic scoping?

It forces variables to be global
It uses more memory during runtime
It results in slower program execution
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
7
Q

What is “scope” in a programming language?

The lifetime of a variable
The place where the variable is stored
The data type of a variable
The region in a program where a variable can be accessed

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
8
Q

If binding time is ________________________, it is considered as dynamic binding.

Execution time
Language definition time
Link time
Translation time

A

Execution time

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

When analyzing nested scopes, why is a stack an appropriate data structure?

Because it supports bidirectional traversal.
Because it maintains a last-in, first-out (LIFO) order, aligning with how nested scopes are entered and exited.
Because it allows elements to be accessed randomly.
Because it provides constant-time access to all variables.

A

Because it maintains a last-in, first-out (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
10
Q

What is the primary purpose of a symbol table in a compiler?

To keep track of syntax rules
To generate machine code
To store information about identifiers
To store program code

A

To store information about identifiers

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