Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q401: What is the correct syntax for a C++ function header?
- A: int foo(int i, int j)
- B: int* foo(int i, int j))
- C: void foo(int i, int j
- D: int* foo(int i, int j)
View Answer
A
Q402: In the expression 'x - 2 * y', which operator has higher precedence?
- A: -
- B: *
- C: +
- D: /
View Answer
B
Q403: What kind of error is caused by 'for(k=0; i < j; j++)' when 'k' is not declared?
- A: Syntax error
- B: Semantic error
- C: Logical error
- D: Runtime error
View Answer
A
Q404: Fill in the blank: The set 'T' in CFG consists of ______.
- A: Terminals
- B: Non-terminals
- C: Productions
- D: Start symbols
View Answer
A
Q405: Which symbol represents the start symbol in CFG?
- A: S
- B: N
- C: P
- D: T
View Answer
B
Q406: What is the result of the production 'expr -> expr op expr'?
- A: A terminal
- B: A non-terminal
- C: A number
- D: An operator
View Answer
B
Q407: What is the meaning of semantic analysis in compiler design?
- A: Checking meaning of statements
- B: Checking syntax
- C: Generating code
- D: Allocating memory
View Answer
A
Q408: Which of the following can be considered a semantic error?
- A: Using undeclared variable
- B: Missing semicolon
- C: Misspelled keyword
- D: Extra parenthesis
View Answer
A
Q409: In CFG, what does 'L(G)' denote?
- A: The language generated by grammar G
- B: The length of G
- C: The lexical tokens of G
- D: The last rule in G
View Answer
A
Q410: Which of these statements about finite automata is correct?
- A: They can remember infinite states
- B: They cannot remember number of times visiting a state
- C: They are used for semantic analysis
- D: They are slower than parsers
View Answer
B