Language Design and Translation Issues MCQ Questions and Answers

1. Which programming language property describes the rules for forming valid sentences (programs) in that language?
A. Semantics
B. Syntax
C. Pragmatics
D. Typing
Answer: B

2. Which of the following is an example of a declarative programming paradigm?
A. Object-oriented programming
B. Procedural programming
C. Functional programming
D. Assembly programming
Answer: C

3. Binding time refers to the time when a language construct is associated with its property. Which of these is a binding time category?
A. Runtime only
B. Compile-only
C. Static and dynamic
D. Interpretive
Answer: C

4. Which translation stage converts source code into an intermediate representation like three-address code?
A. Lexical analysis
B. Syntax-directed translation
C. Intermediate code generation
D. Linking
Answer: C

5. In formal language theory, what class of grammars corresponds to most programming language syntactic definitions?
A. Type-0 grammars
B. Context-free grammars
C. Regular grammars
D. Context-sensitive grammars
Answer: B

6. Which is a primary responsibility of a linker in the translation pipeline?
A. Tokenizing the source code
B. Resolving external symbol references
C. Optimizing runtime performance
D. Parsing expressions
Answer: B

7. Which virtual machine model uses a stack for computations and expression evaluation?
A. Register machine
B. Random access machine
C. Stack machine
D. Cellular automaton
Answer: C

8. What does the term “lexical scoping” mean?
A. Scope determined at runtime by call chain
B. Scope determined by program text structure
C. Scope limited to a single module only
D. Scope that can change during execution
Answer: B

9. Which is an advantage of strong static typing?
A. Faster runtime for all programs
B. Easier dynamic modification of objects
C. Earlier detection of type errors
D. Complete elimination of runtime checks
Answer: C

10. Which of the following is NOT a common compilation phase?
A. Scanner (lexical analysis)
B. Parser (syntax analysis)
C. Semantic analysis
D. Garbage collection
Answer: D

11. In attribute grammars, “synthesized attributes” are computed how?
A. From unrelated modules
B. From child nodes up to parent nodes
C. Only at runtime
D. From parent to child nodes
Answer: B

12. Tail recursion elimination is an optimization commonly used in which paradigm?
A. Imperative OOP
B. Functional programming
C. Assembly programming
D. Event-driven programming
Answer: B

13. Which machine model best captures the behaviour of most modern CPUs when compiling high-level languages?
A. Stack machine only
B. Register machine model
C. Abstract Turing tape machine
D. Lambda calculus machine
Answer: B

14. Which parser type can handle all context-free grammars (but may be inefficient)?
A. LL(1) parser
B. LR(1) parser
C. General CFG parser (like CYK or Earley)
D. Recursive-descent parser without backtracking
Answer: C

15. Which concept is central to object-oriented language design?
A. Continuations
B. Monads
C. Encapsulation
D. Referential transparency
Answer: C

16. In translation, “peephole optimization” operates at which level?
A. High-level source AST
B. Short sequences of target instructions
C. Linking stage only
D. Lexical tokens
Answer: B

17. Which is true about dynamic typing?
A. Types are checked only at compile-time
B. Type checks occur at runtime
C. It prevents any runtime type errors
D. Types are part of the syntax only
Answer: B

18. Which formal model captures function application and higher-order functions?
A. Finite automata
B. Lambda calculus
C. Pushdown automata
D. Petri nets
Answer: B

19. Which translation stage handles symbol table construction and type checking?
A. Code generation
B. Semantic analysis
C. Code emission
D. Optimization
Answer: B

20. Which programming model emphasizes computations as evaluation of expressions without side effects?
A. Imperative model
B. Object-oriented model
C. Functional model
D. Logic model
Answer: C

21. What does “binding” typically mean in programming languages?
A. Executing a program segment
B. Formatting source code
C. Associating names with entities (storage, types, values)
D. Encrypting code
Answer: C

22. Which parsing technique is LL(1) based on?
A. Bottom-up parsing
B. Top-down predictive parsing
C. Shift-reduce parsing
D. Earley parsing
Answer: B

23. Which of the following is a primary design goal of a programming language’s syntax?
A. Make parsing impossible
B. Force low-level programming
C. Ease of understanding and unambiguous parsing
D. Ensure maximum verbosity
Answer: C

24. Which is a distinguishing feature of an interpreted language?
A. Never uses a runtime system
B. Source or intermediate code is executed by another program at runtime
C. Always compiled to native machine code before running
D. No dynamic behavior allowed
Answer: B

25. What is a “virtual computer” in the context of language translation?
A. A physical machine with virtual memory removed
B. An abstract machine that defines semantics and an execution model for a language
C. Any smartphone running apps
D. A real CPU in a cloud environment
Answer: B

26. Which is an essential property of lexical analysis?
A. Checking function types
B. Grouping characters into tokens
C. Emitting machine code
D. Resolving external libraries
Answer: B

27. Which paradigm uses backtracking and unification as core mechanisms?
A. Functional programming
B. Imperative programming
C. Logic programming
D. Event-driven programming
Answer: C

28. Which form of parameter passing copies the argument’s value into the formal parameter?
A. Call-by-reference
B. Call-by-name
C. Call-by-value
D. Call-by-need
Answer: C

29. Which stage of translation typically performs liveness analysis for register allocation?
A. Lexical analysis
B. Optimization (before final code generation)
C. Semantic analysis
D. Linking
Answer: B

30. What is “first-class citizen” in language design?
A. A syntax rule
B. A compilation error
C. An entity that can be passed, returned, and assigned like other values
D. A privileged reserved word
Answer: C

31. Which grammar ambiguity causes multiple parse trees for the same sentence?
A. Left recursion
B. Right factoring
C. Ambiguous grammar
D. LL(1) grammar
Answer: C

32. Which formal transition model describes program execution as transitions between configurations (state, control)?
A. Finite automaton
B. Operational semantics (small-step or big-step)
C. Denotational semantics only
D. Regular expressions
Answer: B

33. Which binding time would attach a format string to an I/O operation at program load time rather than runtime?
A. Runtime binding
B. Load-time (or link-time) binding
C. Compile-time only
D. Never bound
Answer: B

34. In type systems, what does “type inference” do?
A. Enforces dynamic dispatch always
B. Automatically deduces types where not explicitly declared
C. Removes types from a language
D. Changes type safety guarantees to runtime only
Answer: B

35. Which parsing conflict is typical for LR parsers?
A. Predictive conflict
B. Shift-reduce or reduce-reduce conflicts
C. Lexical conflict
D. Semantic conflict
Answer: B

36. Which programming environment tool helps detect memory leaks by monitoring allocations at runtime?
A. Parser generator
B. Memory profiler / leak detector
C. Linker
D. Lexer
Answer: B

37. Which model is best for describing interactive concurrent processes with message passing?
A. Lambda calculus
B. Process calculi (e.g., CSP, π-calculus)
C. Context-free grammars
D. Regular expressions
Answer: B

38. What is the principal purpose of a symbol table in a compiler?
A. To store source code text
B. To generate machine instructions
C. To record identifiers and their attributes for semantic processing
D. To build a runtime stack
Answer: C

39. Which translation technique postpones decisions to runtime by producing code that contains references to runtime checks?
A. Static compilation with full resolution
B. Just-in-time (JIT) compilation or runtime linking techniques
C. Pure interpretation with no code generation
D. Source-to-source only
Answer: B

40. The Church-Rosser property is associated with which model?
A. Finite automata
B. Lambda calculus (reduction confluence)
C. Pushdown automata
D. Regular grammars
Answer: B

41. Which of these is a syntactic mechanism to avoid conflicts in grammars for parsers?
A. Adding more semantic checks only
B. Left-factoring and eliminating left recursion
C. Removing terminals arbitrarily
D. Using ambiguous productions deliberately
Answer: B

42. Which binding associates a variable name with a memory location during program execution?
A. Type binding
B. Address (storage) binding
C. Syntax binding
D. Grammar binding
Answer: B

43. In formal semantics, denotational semantics maps program phrases to what?
A. Token streams
B. Mathematical objects (domains) describing meanings
C. Machine code bytes
D. Parse trees only
Answer: B

44. Which is an advantage of separate compilation and modular translation?
A. Prevents type checking across modules
B. Faster incremental builds and code reuse
C. Requires monolithic linking always
D. Avoids the need for interfaces
Answer: B

45. Which of the following is true about static scope vs. dynamic scope?
A. Static scope depends on runtime call chain
B. Static scope depends on program text; dynamic scope depends on runtime call chain
C. Dynamic scope is resolved by the compiler only
D. They are identical concepts
Answer: B

46. Which formal model is best for describing lexical patterns (tokens)?
A. Context-free grammar
B. Context-sensitive grammar
C. Regular expressions / finite automata
D. Lambda calculus
Answer: C

47. Which optimization technique replaces repeated computations with a stored value?
A. Peephole optimization
B. Common subexpression elimination
C. Dead code insertion
D. Inline inflation
Answer: B

48. Which programming language feature allows code to modify its own structure at runtime?
A. Static typing
B. Reflection / metaprogramming
C. Compile-time-only macros
D. Pure functions only
Answer: B

49. In translation, what does “bootstrapping a compiler” typically mean?
A. Making it run faster on older hardware
B. Using a compiler written in the language it compiles to build that language’s compiler
C. Linking external libraries only
D. Generating documentation automatically
Answer: B

50. Which evaluation strategy delays evaluation until the value is needed and caches the result?
A. Call-by-value
B. Call-by-reference
C. Call-by-need (lazy evaluation)
D. Call-by-name without caching
Answer: C

51. Which of the following is a consequence of left recursion in a grammar for an LL(1) parser?
A. Faster parsing
B. Infinite recursion in naive top-down parsers
C. Guaranteed determinism
D. Better error messages
Answer: B

52. Which language model uses environments mapping variable names to values to define semantics?
A. Turing machine semantics
B. Environment-based operational semantics
C. Finite automaton semantics
D. Regex-based semantics
Answer: B

53. In programming languages, what is “overloading”?
A. Forcing a variable to change type at runtime
B. Having multiple operations or functions with the same name but different signatures
C. Exceeding available memory
D. Adding extra parameters automatically
Answer: B

54. Which technique resolves expression evaluation order and precedence in compilers?
A. Lexical analysis only
B. Parsing using precedence rules or operator-precedence parsing
C. Code generation only
D. Semantic linking only
Answer: B

55. Which property is guaranteed by referential transparency?
A. Expressions change behavior when duplicated
B. An expression can be replaced by its value without changing program behavior
C. Functions can have side effects
D. Memory allocation is deterministic
Answer: B

56. Which of these is a characteristic of virtual machines used for language portability?
A. They always execute native code directly
B. They define a platform-independent instruction set executed by an interpreter or JIT
C. They eliminate the need for garbage collection
D. They require OS-level drivers in each program
Answer: B

57. Which transformation rewrites functions so that there are no nested function definitions and closures are represented explicitly?
A. Dead code elimination
B. Lambda lifting
C. Loop unrolling
D. Strength reduction
Answer: B

58. Which term describes a language feature whose effect requires runtime checks (e.g., bounds-checking arrays)?
A. Pure compile-time feature
B. Dynamic semantics requirement
C. Syntax-only artifact
D. Lexical token
Answer: B

59. Which parsing approach is based on building parse trees from leaves up to the root?
A. Top-down predictive parsing
B. Bottom-up parsing (e.g., LR)
C. Regex-based scanning only
D. Lexical-first parsing
Answer: B

60. What does “currying” transform?
A. A loop into recursion
B. A function of multiple arguments into a sequence of single-argument functions
C. A variable into a constant
D. A class into an object
Answer: B

61. Which of these describes the halting problem in relation to translation tools?
A. A solvable problem for linkers
B. Undecidable general property — can’t determine in general whether arbitrary program halts
C. Easily solved by static analysis always
D. Only relevant to lexical analysis
Answer: B

62. In compiler architecture, what is the role of an intermediate representation (IR)?
A. To replace the parser entirely
B. To provide a machine-independent form suitable for optimization and translation
C. To store end-user documentation
D. To execute the program directly on hardware
Answer: B

63. Which of the following is a correct description of “garbage collection”?
A. Eliminating source code comments
B. Automatic reclamation of memory that is no longer reachable
C. Preventing file I/O errors
D. Optimizing arithmetic expressions
Answer: B

64. Which attribute of a language heavily impacts error detection before execution?
A. Support for GUI libraries
B. Static type system presence and strictness
C. Number of keywords only
D. Choice of IDE only
Answer: B

65. Which of these is a classical static-analysis technique used during compilation?
A. Dynamic bytecode interpretation
B. Dataflow analysis (e.g., reaching definitions, liveness)
C. Runtime reflection
D. JIT compilation only
Answer: B

66. Which semantics style describes meaning by transforming program phrases into mathematical objects and functions?
A. Operational semantics
B. Denotational semantics
C. Axiomatic semantics only
D. Imperative semantics
Answer: B

67. What is a primary risk when using dynamic linking at runtime?
A. Inability to update libraries
B. Version or compatibility mismatches (DLL hell)
C. Slower compile times always
D. Guaranteed faster execution always
Answer: B

68. Which language feature makes serialization and marshaling of closures difficult?
A. Basic arithmetic
B. Capturing of local environment (closures reference runtime context)
C. Static typing only
D. Operator overloading
Answer: B

69. Which optimization transforms recursion into iteration to improve performance?
A. Dead code insertion
B. Tail-call optimization / tail recursion elimination
C. Inline expansion only
D. Loop fusion only
Answer: B

70. Which formal device is primarily used to specify lexical token patterns?
A. Context-free grammar
B. Regular expressions / finite automata
C. Denotational mapping
D. Type systems
Answer: B

71. Which of the following best describes “staging” in multi-stage programming?
A. Running code only once
B. Separating computation into multiple phases where earlier stages generate code for later stages
C. Only relevant to linker scripts
D. The act of committing code to version control
Answer: B

72. What is the main idea behind “continuations” in programming languages?
A. Type inference for variables
B. Representing “the rest of the computation” as a first-class value
C. Automatically garbage-collecting functions
D. Simplifying lexical scopes
Answer: B

73. Which of these is a common cause of parsing ambiguity in expression grammars?
A. Too many keywords
B. Missing operator precedence rules or associativity
C. Lexical rules only
D. Using too many terminals
Answer: B

74. Which of the following languages strongly influenced the design of virtual machines and bytecode systems?
A. Fortran only
B. Java (JVM) and earlier Java-like research)
C. COBOL only
D. BASIC only
Answer: B

75. Which binding time would permit replacing a library implementation after the program is compiled but before execution?
A. Compile-time binding only
B. Link-time or load-time binding depending on system
C. Source-time binding only
D. Never possible
Answer: B

76. Which is a purpose of syntax-directed translation schemes?
A. To skip code generation entirely
B. To attach semantic actions to grammar productions for translation
C. To avoid lexical analysis
D. To improve hardware-level performance directly
Answer: B

77. Which is true about grammar left-factoring?
A. Makes grammars more ambiguous
B. Transforms grammar to help predictive parsers by removing common prefixes
C. Eliminates the need for semantic checks
D. Only used for lexical analysis
Answer: B

78. Which programming model is based around assertions, preconditions, postconditions and Hoare logic?
A. Functional programming
B. Axiomatic semantics / formal verification models
C. Assembly-level programming
D. Prototype-based OOP
Answer: B

79. Which of the following is an example of early binding?
A. Dynamic method dispatch only
B. Compile-time method resolution for non-virtual functions
C. Runtime class loading always
D. Late dynamic linking always
Answer: B

80. Which technique allows a compiler to inline a function?
A. Lexical scoping only
B. Code expansion at call sites replacing call with function body
C. Delaying parsing until runtime
D. Only used in interpreters
Answer: B

81. Which of the following is a benefit of typed intermediate representation in compilers?
A. Prevents code generation always
B. Enables type-directed optimizations and checks
C. Increases ambiguity in parse trees
D. Eliminates need for symbol table
Answer: B

82. What problem does “name mangling” in linkers solve?
A. Slows down linking
B. Distinguishes overloaded or scoped names across modules
C. Removes type safety
D. Automatically optimizes code
Answer: B

83. In formal transition systems, small-step semantics emphasizes what?
A. The full final result only
B. Individual computation steps (granular transitions)
C. Ignoring runtime state altogether
D. Only lexical tokens
Answer: B

84. Which of these is a drawback of purely interpreted languages compared to compiled languages?
A. Easier portability always
B. Typically slower execution performance
C. No runtime flexibility
D. Impossible to debug
Answer: B

85. Which of the following best describes “hoisting” in scope handling?
A. Moving garbage collection earlier
B. Lifting declarations to a broader scope (e.g., function-level)
C. Moving type checks to runtime
D. Delaying parsing operations
Answer: B

86. Which binding mechanism is typically used for dynamic method dispatch in object-oriented languages?
A. Static binding only
B. Late (dynamic) binding via vtables or method tables
C. Compile-time macros only
D. Lexical binding only
Answer: B

87. Which parsing algorithm is typically linear-time and suitable for LR(k) grammars?
A. Recursive descent without lookahead
B. Shift-reduce parsing (LR parsers)
C. CYK algorithm only
D. Regular-expression matching only
Answer: B

88. Which concept allows a compiler to replace a function call by the function body and thus remove call overhead?
A. Garbage collection
B. Inlining
C. Name mangling
D. Left factoring
Answer: B

89. Which of the following is an example of a stage in translation that can be delayed until load-time?
A. Syntax analysis
B. Address relocation and dynamic linking
C. Lexical analysis
D. Tokenization
Answer: B

90. Which semantic approach proves program properties by logical assertions before and after statements?
A. Operational semantics only
B. Axiomatic semantics (Hoare logic)
C. Denotational semantics only
D. Regular expression semantics
Answer: B

91. In compiler error recovery, which strategy attempts to skip input tokens until a synchronizing token is found?
A. Panic mode recovery
B. Panic mode (skipping to synchronizing token)
C. Error productions only
D. Semantic recovery only
Answer: B

92. Which language feature requires conservative copying or special runtime schemes when performing parallel execution?
A. Immutable data only
B. Shared mutable state (aliasing and concurrency issues)
C. Only pure functions
D. Lexical grammar only
Answer: B

93. Which of the following is true about regular grammars?
A. They can express nested parentheses properly
B. They correspond to regular languages recognized by finite automata
C. They can define full programming-language syntax conveniently
D. They are equivalent to context-free grammars
Answer: B

94. Which of these is a technique used to avoid redundant runtime checks inserted by compilation?
A. Inserting more checks always
B. Static analysis to prove checks unnecessary (e.g., range analysis)
C. Removing AST entirely
D. Deferring all checks to users
Answer: B

95. Which virtual-machine feature supports platform independence by abstracting hardware details?
A. Specific CPU instruction compatibility only
B. Bytecode instruction set and runtime interpreter/JIT
C. Direct OS syscalls in source code
D. Hard-coded memory addresses in programs
Answer: B

96. Which model represents computations as relations between input and output states without specifying steps?
A. Small-step operational semantics
B. Denotational semantics (or big-step style / relational semantics)
C. Regular automaton semantics
D. Stack-machine semantics only
Answer: B

97. Which programming-environment tool is primarily used to generate lexical analyzers from regular expressions?
A. YACC only
B. Lex / Flex (lexer generators)
C. Linker generators
D. Interpreter-only tools
Answer: B

98. Which of the following is a correct statement about type safety?
A. It guarantees no runtime errors whatsoever
B. It prevents certain classes of type errors from occurring (depending on language)
C. It is unrelated to compilers or analysis
D. It always requires dynamic typing
Answer: B

99. Which translation-stage technique maps structured control constructs into label-and-goto sequences in target code?
A. Lexical scoping only
B. Control-flow graph construction and lowering (translation to jumps/labels)
C. Garbage collection only
D. Type inference only
Answer: B

100. Which property does an LR(1) parser have compared to an SLR(1) parser?
A. Less lookahead power
B. Stronger (more precise) conflict resolution using full LR(1) items
C. Always faster parsing time in practice
D. Equivalent to regular-expression parsing
Answer: B