A compiler is a program that reads a program written in one language (source language) and translates it into another language (target language). mostly the compiler is used to generate machine code. and to generate the machine code we have different phases to complete. and to study these phases we have a compiler design subject.

In the technical field, we always have to deal with machine code. so it's very important to read about the compiler design process for any technical field. so here we are including basic to advanced compiler design interview questions and answers.

Compiler Design Interview Questions and Answers

In analyzing the compilation of the PL/I program, the term "Machine independent optimization" is associated with

  1. the recognition of basic syntactic construction through reductions.
  2. recognition of basic elements and the creation of uniform symbols.
  3. creation of more optimal matrix
  4. use of the macro processor to produce more optimal assembly code

Answer - (3) creation of the more optimal matrix

In analyzing the compilation of the PL/I program the description "resolving symbolic address (labels) and generating machine language" is associated with

  1. assembly and output
  2. code generation
  3. storage assignment
  4. syntax analysis

Answer - (1) assembly and output

In analyzing the compilation of the PL/I program the description "creation of more optimal matrix" is associated with

  1. assembly and output
  2. code generation
  3. syntax analysis
  4. machine-independent optimization

Answer - (4) machine-independent optimization

Which one is not true about syntax and semantic parts of a computer language

  1. The syntax is generally checked by the programmer.
  2. Semantics is the responsibility of the programmer.
  3. Semantics is checked mechanically by a computer.
  4. Both (b) and (c) above

Answer - (4) Both (b) and (c) above

Left factoring is the process of factoring out the common

  1. prefixed of alternates
  2. suffixes of alternates
  3. predictive parsing
  4. none of the above

Answer - (4) None of the above

In analyzing the compilation of the PL/I program, the term "lexical analysis" is associated with

  1. the recognition of basic syntactic constructs through reductions.
  2. recognition of basic elements and the creation of uniform symbols.
  3. creation of a more optimal matrix.
  4. use of the macro processors to produce more optimal assembly code.

Answer - (2) recognition of basic elements and the creation of uniform symbols

Operator-precedence parsing method is a parsing method. Which of the following statement is false about it?

It is a bottom-up parsing method
It must contain e-production.
It doesn't contain two adjacent nonterminal symbols.

  1. 1 only
  2. 2 only
  3. 3 only
  4. 1 and 3 only

Answer - (2) 2 only

If conversion from one type to another type is done automatically by the compiler then, it is called

  1. implicit conversion
  2. coercions
  3. both (a) and (b)
  4. none of the above

Answer - (3) both (a) and (b)

The term "environment" in programming language semantics is said as

  1. a function that maps a name to value held there
  2. a function that maps a name to a storage location
  3. the function that maps a storage location to the value held there
  4. none of the above

Answer - (2) a function that maps a name to a storage location

A nonrelocatable program is one which

  1. cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation.
  2. consists of a program and relevant information for its relocation
  3. can itself perform the relocation of its address sensitive portions.
  4. all of the above.

Answer - (1) cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation

A self relocating program is one which

  1. cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation.
  2. consists of a program and relevant information for its relocation.
  3. can itself perform the relocation of its address-sensitive portions
  4. all of the above

Answer - (3) can itself perform the relocation of its address-sensitive portions

The linker

  1. is the same as a loader
  2. is require to create a load module
  3. user source code as input
  4. is always used before programs are executed

Answer - (1) is the same as a loader

The translator is best described as

  1. application software
  2. a system software
  3. a hardware component
  4. all of the above

Answer - (2) a system software

Resolution is externally defined symbols is performed by

  1. Linker
  2. Loader
  3. Compiler
  4. Assembler

Answer - (1) Linker

Which of the following derivations does a top-down parser use while parsing an an input string? The input is assumed to be scanned in left to right order.

  1. Leftmost derivation
  2. Leftmost derivation traced out in reverse
  3. Rightmost derivation
  4. Rightmost derivation traced out in reverse

Answer - (1) Left most derivation

A simple two-pass assembler does which of the following in the first pass?

It allocates space for the literal.
It computes the total length of the program.
It builds the symbol table for the symbols and their values.
It generates code for all the loads and stores register instructions.

  1. 1 only
  2. 1 and 2
  3. 1, 2 and 3
  4. 4 only

Answer - (3) 1, 2 and 3

Generation of intermediate code based on an abstract machine model is useful in compilers because

  1. it makes implementation of lexical analysis and syntax analysis easier
  2. syntax-directed translation can be written for intermediate code generation.
  3. it enhances the portability of the front end of the compiler.
  4. it is not possible to generate code for real machines directly from high-level language programs.

Answer - (2) syntax-directed translation can be written for intermediate code generation

A compiler is

  1. A program that places programs into memory and prepares them for execution
  2. a program that automates the translation of assembly language into machine language
  3. a program that accepts a program written in a high-level language and produces an object program
  4. a program that appears to execute a source program as if it were machine language

Answer - (3) a program that accepts a program written in a high-level language and produces an object program

A loader is

  1. a program that places programs into memory and prepares them for execution
  2. a program that automates the translation of assembly language into machine language
  3. a program that accepts a program written in a high-level language and produces an object program
  4. a program that appears to execute a source program as if it were machine language

Answer - (1) a program that places programs into memory and prepares them for execution

Which of the following are language processors?

  1. assembler
  2. compilers
  3. interpreters
  4. all of these

Answer - (1) assembler

Note - More questions and answers will be added from time to time.