Static vs. Dynamic Semantics MCQs December 19, 2025December 14, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. What is the main difference between static and dynamic semantics? (A) Static semantics refers to the syntax of a language, while dynamic semantics refers to the execution of a program. (B) Static semantics checks for syntactic errors, while dynamic semantics checks for logical errors. (C) Static semantics is only concerned with variable declarations, while dynamic semantics is concerned with variable values. (D) Static semantics deals with the meanings of constructs at compile-time, while dynamic semantics deals with the meanings at runtime. 2. Which of the following is an example of static semantics? (A) Type checking during program execution (B) Variable assignment at runtime (C) Ensuring that a variable is declared before it is used (D) Memory allocation during program execution 3. Which of the following issues is typically handled by static semantics? (A) The value of an expression during execution (B) The flow of control in a program at runtime (C) Ensuring that variables are correctly typed and used (D) The actual allocation of memory during execution 4. Dynamic semantics deals with: (A) Syntax of a language (B) Type checking and variable declarations (C) Execution behavior and meaning of the program (D) Grammar rules of a language 5. Which of the following is NOT an example of dynamic semantics? (A) Handling how an assignment affects the value of a variable (B) Determining if a function call is valid during runtime (C) Checking if a variable is properly declared before use (D) Describing the behavior of expressions when evaluated 6. Static semantics errors occur at: (A) During program execution (B) After program execution (C) During the compilation phase, before execution (D) Only when the program is run on different machines 7. Which of the following can be a result of static semantic analysis? (A) Detecting a mismatch between declared and used types of variables (B) A program running out of memory due to excessive recursive calls (C) A function producing incorrect results based on its input (D) A runtime exception due to an invalid array index 8. Which of the following defines dynamic semantics? (A) Defining how an expression is evaluated in a specific machine (B) Describing how variables are allocated in memory (C) Checking if an expression has valid syntax (D) Checking if types match in an expression 9. Which of the following is an example of a dynamic semantic error? (A) Using a variable that was not declared (B) Type mismatches in function arguments (C) Attempting to divide by zero during runtime (D) Incorrect variable scoping during compilation 10. Which statement is true regarding static semantics? (A) It can be checked during runtime (B) It focuses on the meaning of a program’s execution (C) It describes how values of expressions change during execution (D) It checks whether a program adheres to a formal type system and other structural rules