Compiler Design Banner

Compiler Design Multiple Choice Questions (MCQs) and Answers

Master Compiler Design with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Compiler Design concepts. Begin your placement preparation journey now!

Q91

Q91 What is the likely cause of inefficient machine code generation?

A

Suboptimal instruction selection

B

Errors in parsing

C

Type mismatches

D

Incorrect syntax trees

Q92

Q92 What is the primary purpose of a symbol table in a compiler?

A

To store syntax rules

B

To store identifiers and their attributes

C

To generate intermediate code

D

To check for logical errors

Q93

Q93 Which data structure is commonly used to implement a symbol table?

A

Array

B

Stack

C

Hash table

D

Linked list

Q94

Q94 What information is typically stored in a symbol table for variables?

A

Only variable names

B

Names and values

C

Names, types, and scope

D

Syntax and rules

Q95

Q95 What role does the runtime stack play in a runtime environment?

A

Stores variables

B

Manages function calls

C

Holds intermediate code

D

Optimizes machine code

Q96

Q96 Why is dynamic memory allocation handled by the runtime environment?

A

To reduce compile-time errors

B

To improve code readability

C

To handle memory requirements at runtime

D

To optimize machine code

Q97

Q97 How is a new variable added to the symbol table during compilation?

A

It is added by the lexical analyzer

B

It is added by the semantic analyzer

C

It is added by the syntax analyzer

D

It is added by the runtime environment

Q98

Q98 What entry would a function declaration add to a symbol table?

A

Function name only

B

Function name and parameters

C

Function name, parameters, and return type

D

None of the above

Q99

Q99 How are nested scopes managed in a symbol table?

A

Using a single global table

B

Using a stack of symbol tables

C

Using separate files

D

Using intermediate code

Q100

Q100 What error occurs if a variable is not found in the symbol table during compilation?

A

Syntax error

B

Logical error

C

Undefined variable error

D

Runtime error

Q101

Q101 What is the likely issue if a function's return type conflicts with its usage?

A

Semantic error

B

Runtime error

C

Syntax error

D

Memory allocation error

Q102

Q102 How does a runtime environment handle dangling pointers?

A

By automatically freeing memory

B

By detecting and nullifying the pointer

C

By converting pointers to references

D

By ignoring them

Q103

Q103 What is the primary purpose of error detection in a compiler?

A

To ensure code optimization

B

To validate code correctness

C

To parse syntax trees

D

To generate machine code

Q104

Q104 Which phase of the compiler is responsible for detecting syntax errors?

A

Lexical Analysis

B

Syntax Analysis

C

Semantic Analysis

D

Code Generation

Q105

Q105 What is a common method for recovering from errors in a compiler?

A

Backtracking

B

Error messages

C

Panic mode

D

Intermediate code generation

Q106

Q106 Which type of errors are typically detected during semantic analysis?

A

Syntax errors

B

Logical errors

C

Type mismatch errors

D

Memory errors

Q107

Q107 What is the difference between lexical and syntax errors?

A

Lexical errors occur at runtime, syntax errors at compile time

B

Lexical errors involve tokens, syntax errors involve structure

C

Syntax errors involve semantics, lexical errors involve parsing

D

There is no difference

Q108

Q108 What is the error in the following code: if (x > y { z = x; }

A

Lexical error

B

Syntax error

C

Semantic error

D

Runtime error

Q109

Q109 Identify the error in this statement: int x = 5; float y = x + 'a';

A

Lexical error

B

Syntax error

C

Type mismatch

D

Logical error

Q110

Q110 What type of recovery is used if a parser corrects the code to continue?

A

Panic mode recovery

B

Phrase-level recovery

C

Error production recovery

D

Automatic recovery

Q111

Q111 What error will occur if a variable is used without initialization?

A

Syntax error

B

Semantic error

C

Logical error

D

Runtime error

Q112

Q112 What is the likely issue if a compiler reports 'missing semicolon' at an incorrect location?

A

Lexical error

B

Syntax error

C

Semantic error

D

Error propagation

Q113

Q113 What is the primary purpose of a compiler toolchain?

A

To optimize machine code

B

To link libraries

C

To convert source code into executable programs

D

To debug runtime errors

Q114

Q114 Which of the following is an open-source compiler infrastructure?

A

GCC

B

LLVM

C

Clang

D

All of the above

Q115

Q115 What is the role of an assembler in a compiler toolchain?

A

To optimize code

B

To convert assembly code into machine code

C

To link libraries

D

To generate intermediate code

Q116

Q116 Which component of the compiler toolchain is responsible for resolving external references in a program?

A

Compiler

B

Linker

C

Loader

D

Assembler

Q117

Q117 What output is generated by a lexical analyzer generator such as Lex?

A

Intermediate code

B

Token stream

C

Machine code

D

Abstract syntax tree

Q118

Q118 How does Yacc assist in compiler design?

A

It generates lexical analyzers

B

It generates parsers

C

It generates intermediate code

D

It generates machine code

Q119

Q119 What is the most likely issue if a linker reports 'undefined reference' errors?

A

Syntax error

B

Missing library

C

Runtime error

D

Semantic error

Q120

Q120 How can a debugging tool like GDB assist in compiler design?

A

By optimizing machine code

B

By identifying runtime errors

C

By parsing grammar rules

D

By resolving lexical errors

ad verticalad vertical
ad