Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER
/ Interview Guides / Compiler Design MCQ

Compiler Design MCQ

Last Updated: Aug 17, 2023
Certificate included
About the Speaker
What will you Learn?
Register Now

Compiler -  It is a software program that converts a program written in High-level language to a low-level language(object/ target language). It also reports errors present in source programs.

Types of compilers:

  • Single-pass compilers: It is a type of compiler that processes the source code only once.
  • Multi-pass compilers: It is a type of compiler that processes the source code multiple time(to convert High-level language to Low-level language) i.e. to convert source code to target/ object code.

There are two phases of the compilation process:

  • Analysis: It breaks up the source code/program into small parts and creates an intermediate representation of the source program.
  • Synthesis phase: It takes the intermediate representation of the source program as input and creates the desired target code/program.

There are five phases of a compiler:

Lexical analyzer 

  • Reads the program and converts it into tokens using the LEX tool.
  • Tokens are defined by regular expressions which are understood by the lexical analyzer
  • Removes white spaces, comments, tabs.

Syntax analyzer

  • Constructs the parse tree.
  • Takes the tokens one by one and uses CFG to construct the parse tree.
  • Using these productions we can represent what the program actually is.
  • The input has to be checked whether it is in the desired format or not.

Semantic analyzer

  • Verifies the parse tree, whether it is meaningful or not.
  • It uses the parse tree and info in the symbol table to check the source program for semantic consistency with the language definition.

Intermediate code generator

  • Generates the intermediate code. Example: Three address codes.
  • This code is converted to machine language using the last two phases which are platform dependent. 

Code optimizer

  • We can get optimized code.
  • The code optimization phase attempts to improve the intermediate code so that it runs faster and consumes fewer resources.

Target code generator

  • The final phase of the compiler generates the target code/assembly code.

Symbol Table

  • The data structure is used by the compiler to store all the information related to identifiers, for example, their types, scope, location name, etc.
  • It helps the compiler to function smoothly by finding the identifiers quickly.
  • All the phases interact with the symbol table manager.

Error handler

It is a module that takes care of the events which are encountered during compilation and it takes care to continue the compilation process even if the error is encountered. The task of the error handling process is to detect each error, report it to the user and implement them to handle errors.

Grammars

It is basically a set of rules that defines the valid structure of a particular language.

A grammar consists of four components:

  • Set of terminals: They are not replaced by any other thing further.
  • Set of non-terminals: Values/variables that are replaced by terminals.
  • Set of productions
  • Start symbol: One of the non-terminals is designated as the start symbol from where the production begins.

Compiler Design MCQs

Crack your next tech interview with confidence!
Take a free mock interview, get instant⚡️ feedback and recommendation💡
Explore free masterclasses from our top instructors
Live Masterclass
Taught by top industry experts
Access to learning material
No More Events to show!
No More Events to show!
No More Events to show!
No More Events to show!
Certificate included
About the Speaker
What will you Learn?
Register Now
View All
1. 

What is the action of parsing the source program into proper syntactic classes known as?

2. 

What does a bottom-up parser generate?

3. 

What is the bottom-up parsing method also known as?

4. 

Identify the method which merges the bodies of two loops?

5. 

Which of the compiler allows the only modified sections of source code to be recompiled?

6. 

Identify the data structure which has minimum access time in case of symbol table implementation?

7. 

What does a top-down parser generate?

8. 

Identify the most powerful parser?

9. 

Through which type of grammar can synthesized attributes can be simulated?

10. 

Another name of top-down parsing is?

11. 

Identify the most general phase of structured grammar.

12. 

Identify the technique used to replace run-time computations with compile-time computations.

13. 

Identifying the class of statement when compiled does not produce any executable code.

14. 

What does the lexical analyzer take as input?

15. 

What does the lexical analyzer take as output?

16. 

What is a linear analysis called in a compiler?

17. 

Identify the correct definition of lexical analysis?

18. 

On what basis is the phase syntax analysis modeled?

19. 

What is the role of optimizing the compiler?

20. 

What is the compiler called which runs on one machine and produces code for a different machine?

21. 

What is the graph called which shows basic blocks along with their successor relationship?

22. 

What is the action of parsing the source program into proper syntactic classes known as?

23. 

Which part produces the target code from the intermediate representation of source code?

24. 

Identify the method to determine whether tokens can be generated by a given grammar?

25. 

Which parsing technique avoids backtracking?

26. 

What of the following can recognize Context-sensitive grammar?

27. 

Identify the data structure which is based on the locality of reference used for implementation of the symbol table.

28. 

What is the process of searching for match tokens described using?

29. 

When is an interpreter preferred over a compiler?

30. 

Identify which among the following is used for grouping characters into tokens.

31. 

When is type checking done?

32. 

Identify the term which is recognized as a sequence of characters in token.

33. 

What does LR stand for?

34. 

In which class does recursive descent parsing belong?

35. 

Why is the minimum Hamming distance method used?

36. 

Which of the following errors can a compiler check?

37. 

Why is the symbol table used?

38. 

Identify the language processor among the following.

39. 

Why is handle pruning used?

40. 

When can semantic errors be detected?

41. 

Identify the correct phase of the compiler.

42. 

In which does the compiler translate the source code?

43. 

In which phase of the compiler is grammar checked?

44. 

Why is semantic analysis responsible for?

45. 

Identify the interpreted language.

46. 

What is the process of finding a parse tree for a string of tokens called?

47. 

In which language do users write the programs?

48. 

Check whether the following statement is true or false: Ambiguous grammar produces more than one parse tree for some sentence.

49. 

Identify the output of the assembler.

Scaler Courses
Why Scaler Premium?
Premium
Explore Scaler Premium Program and unlock a world of benefits
We have received your request. Someone from our team will soon connect with you
Structured Curriculum
Experience expert-led learning with our industry-proven curriculum
1:1 Mentorship Sessions
Learn from industry experts with our personalised 1:1 Mentorship
Career Support
We're dedicated to helping you achieve your career goals
Excel at your interview with Masterclasses Know More
Certificate included
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Non Coder
Other
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test