NEW
Font size
WorksheetsPL Final Exam
Total questions: 70
Worksheet time: 35mins
The region or part of a program where a variable is accessible.
Scope
Loop
Function
Class
The ability of a language to allow a small number of constructs to be combined freely without restrictions.
Orthogonality
Encapsulation
Polymorphism
Inheritance
The type of semantics that describes how a program executes step-by-step.
Operational Semantics
Denotational Semantics
Axiomatic Semantics
Contextual Semantics
The degree to which programs perform correctly and consistently under all circumstances.
Reliability
Portability
Efficiency
Maintainability
What x:=x+1 represents in Operational Semantics if the initial state is S(x=5).
S(x=6)
S(x=5)
S(x=4)
S(x=7)
The process of associating a variable name with a memory location or value.
Binding
Casting
Looping
Referencing
The type of semantics that uses Hoare Triples ( {P} \text{statement} {Q} ) to describe program correctness.
Axiomatic Semantics
Operational Semantics
Denotational Semantics
Syntax-Directed Semantics
The concept that allows inner scopes to access variables from outer scopes, but not vice versa.
Static Scoping
Dynamic Binding
Lexical Analysis
Runtime Polymorphism
The specific component of an Activation Record that points to the caller's activation record.
Dynamic Link
Return Address
Control Link
Access Link
The binding time for the meaning of the plus operator (+) as addition.
Language Definition Time
Compilation Time
Linking Time
Execution Time
The type of typing where errors may appear only during runtime.
Dynamic Typing
Static Typing
Strong Typing
Duck Typing
The degree to which a language allows programmers to express ideas or structures in code easily.
Readability
Efficiency
Portability
Security
The logical assertion that must be true before the execution of a statement in Axiomatic Semantics.
Precondition
Postcondition
Invariant
Predicate
The concept of an Activation Record that allows a function to return to the correct place after execution.
Return Address
Stack Pointer
Frame Pointer
Local Variables
The characteristic of a language that determines if it allows implicit conversions between different data types.
Type Compatibility
Syntax Highlighting
Memory Allocation
Error Handling
The concept described by the phrase, "Variables declared inside a block shadow variables with the same name in outer scopes".
Variable Shadowing
Variable Hoisting
Variable Scoping
Variable Binding
The total expense of using, developing, and maintaining code in a language.
Cost
Syntax
Performance
Portability
The type of typing where variable types must be declared explicitly.
Static Typing
Dynamic Typing
Duck Typing
Implicit Typing
The type of semantics that describes what a program computes as a mathematical function.
Denotational Semantics
Operational Semantics
Axiomatic Semantics
Syntactic Semantics
Binding that happens before runtime, such as variable types in the C language.
Static Binding
Dynamic Binding
Late Binding
Runtime Binding
The primary focus of Syntax in programming languages is:
What the program actually does
How the program is written
Why the program is correct
The mathematical function it computes
A primary feature of high writability languages is:
Static type checking
Low control over the machine
Rich built-in operations and concise syntax
Enforced block scoping
In Operational Semantics, behavior is defined by changes in:
Mathematical function
Hoare Triple
State (State transitions)
Activation Record
Python’s type system is:
Static & Weakly Typed
Dynamic & Weakly Typed
Static & Strongly Typed
Dynamic & Strongly Typed
Major contributor to a language’s Maintenance Cost:
Speed of execution
Low writability
High readability
Learning curve
Direction: Encircle or underline the correct answer. 26. Primary representation in Denotational Semantics:
State transition arrow
Hoare Triple
Mathematical function
Runtime stack
Static (Lexical) Scoping means:
Depends on call sequence
Types fixed at runtime
Depends on code structure
Binding at compile time
Handling exceptions gracefully increases:
Readability
Writability
Reliability
Cost
Memory block created for a function call is:
Access Link
Activation Record
Global Scope
Control Link
Language less reliable due to pointers/manual memory:
Python
Java
C
C++
In Hoare Triple {P} statement {Q}, correctness is guaranteed by:
P
Statement
Q
Whole triple
Static typing advantage:
Errors caught early (compile-time)
Easier to modify
Types change at runtime
Less code
Dynamic (Late) Binding occurs at:
Compile Time
Link Time
Language Definition
Run Time
Direction: Encircle or underline the correct answer. 34. Global variable declared:
Inside loop
Inside function
Outside all functions
In another file
Real-life analogy for Operational Semantics:
Contract
Cooking recipe
Mathematical function
High-level summary
Access Link points to:
Next line
Caller’s record
Non-local variables
Saved registers
Trade-off with high writability:
High readability
Control over the machine
Low cost
Expressivity
When two functions call each other recursively:
One record used
Only parameters saved
Multiple activation records created
Uses heap
Expressivity feature improving writability:
Exception handling
Static type checking
List comprehensions
Block scoping
In strongly typed languages, "5" + 2 results in:
Crash
Implicit conversion
TypeError
Warning
Semantics defines the meaning or behavior of programs, while Syntax defines how programs are written (the form).
True
False
An advantage of Operational Semantics is that it abstracts away execution details, focusing only on the result.
True
False
In Denotational Semantics, the sequence of statements x:=3;y:=x+2; is evaluated by applying the meaning of y:=x+2 first, then x:=3 .
True
False
Readability is considered less important than Writability because a program spends most of its life being executed by machines.
True
False
Simplicity is a factor that improves both Readability and Writability.
True
False
The Execution Cost of a language refers to the time and effort required to learn it.
True
False
A language with Weak Typing enforces strict type compatibility and results in more type errors.
True
False
In a language with Dynamic Typing, the type of a variable can change during runtime.
True
False
In static scoping, the compiler determines the scope from the code layout (lexical structure).
True
False
The Control Link in an Activation Record points to non-local variables.
True
False
Static (Early) Binding is generally associated with higher performance because decisions are made before runtime.
True
False
In the Hoare Triple extstatement , the Postcondition Q defines what must be true before execution.
True
False
The availability of clear and high-level data structures (like lists and dictionaries) improves a language's Readability.
True
False
Recursion requires the creation of multiple Activation Records for the same function on the runtime stack.
True
False
The total cost of a language includes only the time taken to design, code, and debug (Development Cost).
True
False
Aliasing Control is a factor that reduces unintended side effects from shared references, thereby improving Reliability.
True
False
Dynamic Scoping is used in modern languages like Python and C++.
True
False
The expression $[\begin{matrix}x&=&x+1&](s)&=s[x\mapsto&s(x)+1\end{matrix}]$ is a representation used in Denotational Semantics.
True
False
A Local Scope variable declared inside a function is accessible anywhere in the program.
True
False
Improving one evaluation criterion (e.g., Readability) often requires a trade-off that reduces another (e.g., Control over the machine)
True
False
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 61-62
Precondition (P): { ? }
Statement (v:=e): x := x + 5
Postcondition (Q): { x = 12 }
What is the missing precondition?
{ x = 7 }
{ x = 12 }
{ x = 17 }
{ x = 5 }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 63-64
Precondition (P): { y = 3 }
Statement (v:=e): y := y * 4
Postcondition (Q): { ? }
What is the missing postcondition?
{ y = 12 }
{ y = 7 }
{ y = 3 }
{ y = 4 }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 65-66
Precondition (P): { a = 9 }
Statement (v:=e): { ? }
Postcondition (Q): { a = 1 }
What is the missing statement?
a := 1
a := 9
a := a + 1
a := 0
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 67-68
Statement (v:=e): z := z - 3
Postcondition (Q): { z < 5 }
What is the missing precondition?
{ z < 8 }
{ z < 2 }
{ z < 5 }
{ z < 3 }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 69-70
Precondition (P): { p = 10 }
Statement (v:=e): p := p / 2
Postcondition (Q): { ? }
What is the missing postcondition?
{ p = 5 }
{ p = 20 }
{ p = 2 }
{ p = 10 }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 71-72
Precondition (P): { b = 2 }
Statement (v:=e): { ? }
Postcondition (Q): { b = 16 }
What is the missing statement?
b := 16
b := 2
b := b + 2
b := 8
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 73-74
Precondition (P): { ? }
Statement (v:=e): c := d
Postcondition (Q): { c = 20 }
What is the missing precondition?
{ d = 20 }
{ c = 20 }
{ d = c }
{ c = d }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 75-76
Precondition (P): { x > 0 }
Statement (v:=e): x := x + 1
Postcondition (Q): { ? }
What is the missing postcondition?
{ x > 1 }
{ x > 0 }
{ x >= 0 }
{ x < 0 }
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 77-78
Precondition (P): { k = 5 }
Statement (v:=e): { ? }
Postcondition (Q): { k = 5 }
What is the missing statement?
k := 5
k := 0
k := k + 1
k := 10
Direction: Fill in the missing part ({ ? }) for the assignment statement using the Assignment Axiom of Axiomatic Semantics.
No. 79-80
Statement (v:=e): m := 2
Postcondition (Q): { m != 3 }
What is the missing precondition?
{ } (any value for m, since m := 2 will always make m != 3)
{ m = 3 }
{ m > 2 }
{ m < 2 }
