Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q371: Why are regular expressions not suitable for syntax representation of programming languages?
- A: They are too complex
- B: They lack memory of repeated states
- C: They are slow
- D: They do not support tokens
View Answer
B
Q372: In CFG notation G = (S, N, T, P), what does 'P' represent?
- A: Start symbol
- B: Non-terminals
- C: Productions
- D: Terminals
View Answer
C
Q373: What does the start symbol 'S' in a Context-Free Grammar represent?
- A: A terminal symbol
- B: The beginning of a derivation
- C: A production rule
- D: A non-terminal symbol
View Answer
B
Q374: Which of the following is NOT a component of a Context-Free Grammar?
- A: Terminals
- B: Non-terminals
- C: Attributes
- D: Start symbol
View Answer
C
Q375: In parsing, what is the difference between leftmost and rightmost derivation?
- A: Leftmost replaces rightmost non-terminal
- B: Rightmost replaces leftmost non-terminal
- C: Leftmost replaces leftmost non-terminal, Rightmost replaces rightmost non-terminal
- D: No difference
View Answer
C
Q376: What is the correct boolean expression syntax for a for loop?
- A: for(i=0; i
- B: for(k=0; i j;)
- C: for(i=0; j
- D: for(i=0 i
View Answer
A
Q377: In semantic analysis, the sentence "He wrote the computer" is
- A: Correct
- B: Incorrect due to syntax
- C: Incorrect due to semantics
- D: Correct but incomplete
View Answer
C
Q378: Which language's syntax influenced C, C++, and Java?
- A: JavaScript
- B: Algol-60
- C: Python
- D: COBOL
View Answer
B
Q379: Which form was developed by John Backus and adapted by Peter Naur for Algol-60?
- A: Regular Expression
- B: Backus-Naur Form (BNF)
- C: Chomsky Normal Form
- D: Extended BNF
View Answer
B
Q380: Which of the following is an example of a terminal symbol in CFG?
- A:
- B:
- C: +
- D:
View Answer
C