Programming Fundamentals 1
4.0 Credits
Final Exam Review (Qns & Ans)
2025
©2025
, Multiple Choice Questions
Question 1:
In programming language implementation, which statement best
distinguishes static (compile‑time) binding from dynamic (run‑time)
binding?
A. Static binding is resolved at compile time, while dynamic binding
is determined during program execution.
B. Static binding uses dynamic type inference, whereas dynamic
binding uses explicit declarations.
C. Static binding is resolved during linking, and dynamic binding
occurs only in interpreted languages.
D. Static binding applies only to variable declarations, while
dynamic binding applies only to function calls.
Correct ANS: A
Rationale:
Static binding (or early binding) resolves identifiers and function
calls during compile time, whereas dynamic binding (or late
binding) defers this resolution until runtime, often to support
polymorphism.
---
Question 2:
Which method of memory management is used in languages with
automatic garbage collection?
A. Manual deallocation using delete/free
B. Reference counting combined with a mark-and-sweep algorithm
C. Stack unwinding upon function exit
D. Allocating memory on the heap without reclamation
Correct ANS: B
Rationale:
Languages with garbage collection (e.g., Java, C ) typically use
algorithms such as mark-and-sweep (often combined with
©2025
, reference counting) to automatically reclaim memory that is no
longer accessible.
---
Question 3:
Tail recursion optimization is significant in programming because:
A. It eliminates all forms of recursion errors.
B. It allows a tail‑recursive function to execute in constant stack
space.
C. It converts recursive calls into iterative loops during the linking
phase.
D. It ensures that recursion always runs faster than iteration.
Correct ANS: B
Rationale:
Tail recursion optimization reuses the current function’s stack frame
for a tail‑recursive call, thereby reducing the additional memory
overhead typically associated with recursion.
---
Question 4:
Which parameter passing mechanism allows changes made within
a function to affect the original argument?
A. Pass-by-value
B. Pass-by-reference
C. Pass-by-constant
D. Pass-by-copy-restore
Correct ANS: B
Rationale:
Pass-by-reference passes the actual reference (or address) of the
variable, so modifications within the function are reflected in the
original variable.
---
©2025