Language design and translation: paradigms, binding times, syntax, stages in translation and formal models. - Question Bank

1. In programming languages, 'static binding' (early binding) occurs:
A) During the execution of the program.
B) When the program is loaded into memory.
C) Before the program begins execution (e.g., at compile time).
D) When a function is first called.
2. The translation process of a compiler can be broadly divided into two main phases: analysis and synthesis. Which of the following belongs to the synthesis phase?
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Generation
3. Which formal language model is typically used to describe the syntax recognized by a lexical analyzer?
A) Context-Free Grammar
B) Finite Automata
C) Turing Machine
D) Pushdown Automata
4. What is 'late binding' (dynamic binding) primarily concerned with?
A) Resolving references at compile time.
B) Delaying the resolution of references until runtime.
C) The initial definition of language syntax.
D) The order of tokens in a source file.
5. The paradigm that models computation as the evaluation of mathematical functions is:
A) Imperative Programming
B) Object-Oriented Programming
C) Functional Programming
D) Procedural Programming
6. Which of the following is an example of a binding that occurs at Language Definition Time?
A) The value of a variable.
B) The type of an operator.
C) The memory address of a function.
D) The scope of a local variable.
7. What is the role of 'code generation' in a compiler?
A) To check for semantic errors.
B) To produce the target machine code or bytecode.
C) To break the source code into tokens.
D) To create an abstract syntax tree.
8. A 'lambda expression' is a feature commonly found in:
A) Imperative Programming
B) Object-Oriented Programming
C) Functional Programming
D) Logic Programming
9. Which binding time is associated with the allocation of memory for global variables?
A) Compile Time
B) Load Time
C) Execution Time
D) Language Definition Time
10. What is a common representation for the output of a syntax analyzer?
A) A sequence of tokens
B) A parse tree or abstract syntax tree
C) Machine code
D) Symbol table entries
11. The 'declarative' programming paradigm focuses on:
A) How to achieve a result (sequence of steps).
B) What the result should be, without specifying the control flow.
C) Modifying program state through assignments.
D) The use of mutable data structures.
12. Which stage of translation is responsible for converting the program into a format that is closer to machine code?
A) Lexical Analysis
B) Syntax Analysis
C) Intermediate Code Generation
D) Semantic Analysis
13. What is 'inheritance' in object-oriented programming?
A) The ability for objects to be created from a class.
B) The process where a new class derives properties and behaviors from an existing class.
C) The mechanism of bundling data and methods.
D) The ability to call methods on different types of objects.
14. The binding of a constant's value occurs at:
A) Execution Time
B) Load Time
C) Compile Time or Language Definition Time
D) Syntax Analysis Time
15. Which type of grammar is powerful enough to describe most programming language syntaxes but not all possible computer programs?
A) Regular Grammar
B) Context-Sensitive Grammar
C) Context-Free Grammar
D) Unrestricted Grammar
16. What is the primary goal of semantic analysis?
A) To verify that the program adheres to the language's grammatical rules.
B) To check for type errors and other logical inconsistencies.
C) To convert the source code into a sequence of machine instructions.
D) To break the source code into individual tokens.
17. In functional programming, 'immutability' means:
A) Functions can only be called once.
B) Data cannot be changed after it is created.
C) Programs must execute in a specific order.
D) Side effects are encouraged.
18. Which binding time is generally the earliest?
A) Execution Time
B) Compile Time
C) Language Definition Time
D) Load Time
19. What is the role of a 'parser' in a compiler?
A) To convert source code into tokens.
B) To check the meaning and consistency of statements.
C) To build a parse tree or AST from the token stream.
D) To generate machine code.
20. The concept of 'state' is central to which programming paradigm?
A) Functional Programming
B) Logic Programming
C) Imperative Programming
D) Declarative Programming
21. Which phase of translation is responsible for generating optimized code?
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Optimization
22. What does 'polymorphism' mean in the context of object-oriented programming?
A) The ability to inherit properties from multiple parent classes.
B) The ability of an object or method to take on many forms.
C) The process of combining data and methods into a single unit.
D) The mechanism for hiding implementation details.
23. The binding of a variable to a specific memory location typically occurs at:
A) Compile Time
B) Load Time or Execution Time
C) Language Definition Time
D) Syntax Analysis Time
24. Which programming language paradigm is closely associated with lambda calculus?
A) Procedural Programming
B) Object-Oriented Programming
C) Functional Programming
D) Logic Programming
25. A 'recursive descent parser' is a type of:
A) Lexical Analyzer
B) Syntax Analyzer
C) Semantic Analyzer
D) Code Generator
26. What is the purpose of a symbol table in a compiler?
A) To store the machine code generated from the source program.
B) To store information about identifiers (variables, functions, etc.) and their attributes.
C) To perform type checking on program variables.
D) To manage the memory allocation for the program.
27. Which binding time is associated with the resolution of function calls to their definitions?
A) Compile Time
B) Load Time
C) Execution Time
D) Language Definition Time
28. In object-oriented programming, 'encapsulation' refers to:
A) The ability of an object to take on many forms.
B) The bundling of data (attributes) and methods (functions) that operate on the data.
C) The process of creating new classes from existing ones.
D) The mechanism by which objects communicate with each other.
29. What is the main advantage of using an intermediate representation like an AST?
A) It directly maps to specific machine hardware.
B) It simplifies the implementation of a compiler by separating analysis and synthesis phases.
C) It is the final output of the compilation process.
D) It is primarily used for debugging user programs.
30. Which of the following is a common method for defining the syntax of programming languages?
A) Regular Expressions
B) Backus-Naur Form (BNF)
C) Flowcharts
D) Decision Trees
31. The binding of a variable's scope to its declaration typically occurs at:
A) Execution Time
B) Compile Time
C) Load Time
D) Runtime Initialization
32. What is an 'abstract syntax tree' (AST)?
A) A linear sequence of tokens representing the source code.
B) A hierarchical representation of the source code's structure.
C) A set of machine instructions.
D) A table storing symbol information.
33. Which stage of translation involves checking for type compatibility and other consistency rules not covered by syntax?
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Optimization
34. What is the primary characteristic of the 'imperative' programming paradigm?
A) Focus on mathematical functions and immutability.
B) Use of statements that change a program's state.
C) Declaration of facts and rules for logical deduction.
D) Modeling computation as the evaluation of mathematical functions.
35. When is the binding of a variable's value to its identifier typically performed in an imperative language?
A) At compile time only
B) At load time only
C) At execution time
D) At definition time
36. The process of converting an abstract syntax tree (AST) into a sequence of machine instructions is called:
A) Lexical Analysis
B) Syntax Analysis
C) Semantic Analysis
D) Code Generation
37. Which paradigm uses 'if-then' rules and logical inference as its core mechanism?
A) Imperative Programming
B) Logic Programming
C) Event-Driven Programming
D) Concurrent Programming
38. A context-free grammar is a formal system used to describe:
A) The runtime behavior of programs.
B) The memory usage of variables.
C) The syntax of programming languages.
D) The efficiency of algorithms.
39. What is the primary purpose of intermediate code generation in a compiler?
A) To directly produce machine code for a specific architecture.
B) To represent the source program in a machine-independent form.
C) To perform syntax checking.
D) To optimize the user interface.
40. Which of the following is an example of a binding that typically occurs at execution time?
A) Function call parameters
B) Variable declaration
C) Operator precedence
D) Language keywords
41. What is a 'token' in the context of lexical analysis?
A) A keyword in the programming language.
B) A basic building block of the source code, like an identifier or operator.
C) A complete program statement.
D) A comment in the code.
42. Semantic analysis in a compiler focuses on:
A) The structure of statements.
B) The meaning of statements.
C) The sequence of characters.
D) The memory allocation for variables.
43. Which programming paradigm is characterized by the evaluation of functions and avoiding side effects?
A) Imperative Programming
B) Object-Oriented Programming
C) Functional Programming
D) Declarative Programming
44. The binding of a variable's type to its identifier can occur at which of the following times?
A) Compile time
B) Load time
C) Execution time
D) All of the above
45. Which formal model is commonly used to describe the syntax of programming languages using a set of production rules?
A) Finite Automata
B) Pushdown Automata
C) Context-Free Grammar
D) Turing Machine
46. What is the main role of a lexical analyzer (scanner) in a compiler?
A) To group tokens into meaningful constructs.
B) To convert source code into a sequence of tokens.
C) To optimize the generated machine code.
D) To check for type errors.
47. Which stage of translation is primarily responsible for checking the grammatical correctness of the source code according to the language's syntax rules?
A) Lexical Analysis
B) Syntax Analysis (Parsing)
C) Semantic Analysis
D) Code Generation
48. What is the primary goal of defining the syntax of a programming language?
A) To specify the meaning of program statements.
B) To define the structure and arrangement of symbols.
C) To determine the execution efficiency of code.
D) To ensure memory management is handled correctly.
49. In programming language design, what does 'binding time' refer to?
A) The time at which a variable's value is determined.
B) The time at which a variable name is declared.
C) The time at which a variable's type is checked.
D) The time at which a program starts execution.
50. Which programming paradigm emphasizes the concept of 'objects' with associated data and methods?
A) Functional Programming
B) Procedural Programming
C) Object-Oriented Programming
D) Logic Programming