wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Compiler Design Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which of the following is true about an interpreter compared to a compiler?

a)

Interpreter is faster in execution than compiler.

b)

Interpreter requires less memory.

c)

Interpreter executes source program line by line.

d)

Interpreter generates intermediate code.

2.

A startup develops a mobile app in Python but wants to release the same in C for performance. Which translator is needed?

a)

Interpreter

b)

Compiler

c)

Cross-compiler

d)

Assembler

3.

A new IoT device has only 1KB RAM and needs fast execution. Which approach should the company choose?

a)

Interpretation

b)

Compilation

c)

Hybrid (bytecode + VM)

d)

None

4.

Which of the following language processors uses two passes – one for analysis and another for synthesis?

a)

Linker

b)

Loader

c)

Compiler

d)

Interpreter

5.

The output of a lexical analyzer is:

a)

Parse tree

b)

Syntax tree

c)

Set of tokens

d)

Machine code

6.

A compiler detects undeclared variable use. Which phase finds this error?

a)

Lexical analysis

b)

Syntax analysis

c)

Semantic analysis

d)

Code generation

7.

Intermediate code in a compiler is generated to:

a)

Increase execution speed

b)

Make compiler design machine independent

c)

Optimize source program

d)

Reduce parsing time

8.

In an online judge system (like HackerRank), code is converted to an intermediate representation before execution. Which compiler phase handles this?

a)

Lexical analysis

b)

Intermediate code generation

c)

Optimization

d)

Symbol table management

9.

If a compiler reports 'missing semicolon', which phase identifies it?

a)

Lexical

b)

Syntax

c)

Semantic

d)

Code generation

10.

Which phase is directly responsible for mapping identifiers to memory locations?

a)

Lexical

b)

Semantic

c)

Symbol table management

d)

Code generation

11.

Which of the following is not a token?

a)

Identifier

b)

Keyword

c)

Comment

d)

Constant

12.

A text editor must highlight keywords while typing. Which compiler phase’s functionality is mimicked?

a)

Semantic

b)

Syntax

c)

Lexical analysis

d)

Optimization

13.

Why is input buffering required in lexical analysis?

a)

To store tokens

b)

To speed up token recognition

c)

To minimize I/O operations

d)

Both b and c

14.

In compiler design, the end-of-file is generally denoted by:

a)

Blank space

b)

Null token

c)

EOF symbol

d)

End of string

15.

A web browser is parsing an HTML file. Which stage will detect as an invalid tag?

a)

Lexical analyzer

b)

Parser

c)

Semantic analyzer

d)

Intermediate code generator

16.

Which of the following statements is true?

a)

Every DFA is also an NFA.

b)

Every NFA is also a DFA.

c)

NFA and DFA have different expressive power.

d)

None of these.

17.

Convert regular expression (a|b)*abb into DFA. How many states minimum?

a)

3

b)

4

c)

5

d)

6

18.

A spam filter marks any email containing 'win' or 'free'. Which concept is applied?

a)

Context-free grammar

b)

DFA from regular expressions

c)

Semantic analysis

d)

Pushdown automata

19.

Which of the following is regular?

a)

{anbn|n≥0}

b)

{w ∈ {0,1}*|w has equal 0s and 1s}

c)

{w|w is palindrome over {a,b}}

d)

{w|number of a’s is divisible by 3}

20.

A digital lock accepts only strings ending with 101. Which automaton models this?

a)

NFA with 3 states

b)

DFA with 4 states

c)

DFA with 3 states

d)

PDA

21.

Which regular expression denotes binary strings divisible by 2?

a)

(0|1)0

b)

(0|1)1

c)

0

d)

(0|1)

22.

Minimizing DFA is done to:

a)

Reduce transition count

b)

Reduce execution time

c)

Improve memory efficiency

d)

All of these

23.

Which of the following languages is not regular?

a)

{0n|n≥0}

b)

{0n1n|n≥0}

c)

{w|w contains substring 010}

d)

{w|w ends with 00}

24.

A company wants to develop a tool that converts log files into structured JSON format. Which compiler tool is closest?

a)

Parser

b)

Lex tool

c)

Assembler

d)

Loader

25.

Which of the following is NOT a function of Lex tool?

a)

Token recognition

b)

DFA construction

c)

Syntax tree generation

d)

Automating lexical analysis