Computer Knowledge

Programming Languages and Compilers

1,170 Questions

Programming languages and compilers involve the rules, syntax, and semantics used to write and execute software programs. Key areas include scripting languages, object oriented concepts, and parsing algorithms like top down parsers. Practice these computer science questions to build proficiency for technical and computer knowledge exams.

Object oriented languagesScripting languagesCompilers and parsersProgramming syntax

Programming Languages and Compilers Questions

Multiple choice
  1. programming languages

  2. register counter

  3. location counter

  4. instruction counter

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Macro languages allow programmers to define shorthand for sequences of instructions, which are then expanded by a macro processor. This system provides a way to extend a base language, making it a specialized form of programming language. Unlike counters, which track addresses or values, macro languages focus on code abstraction and generation.

Multiple choice
  1. system parsing

  2. programming parsing

  3. bottom up parsing

  4. none of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In compiler theory, parsing is the process of determining the grammatical structure of a sequence of tokens. The two primary strategies for this are top-down parsing, which builds the parse tree from the root down to the leaves, and bottom-up parsing, which starts from the leaves and works up to the root. These two methods cover the vast majority of parsing algorithms used in computer science.

Multiple choice
  1. storage allocation

  2. lexical analysis

  3. semantic analysis

  4. none of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A compiler is divided into analysis and synthesis phases. The synthesis phase is responsible for taking the analyzed source code and producing the target machine code, which involves storage allocation for variables and the actual generation of instructions. Lexical and semantic analysis are part of the analysis phase, which occurs before synthesis.

Multiple choice
  1. to convert high level language into machine level language.

  2. to convert high level language into assembly language

  3. to convert assembly language into machine level language

  4. all of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The primary definition of a compiler is a program that translates high-level language (HLL) source code into machine-level language (object code). While some compilers may output assembly language as an intermediate step, the ultimate task that distinguishes a compiler from an assembler is the conversion from a high-level abstraction to a machine-executable format. Option C describes an assembler, not a compiler.

Multiple choice
  1. BASIC

  2. FORTRAN

  3. C

  4. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Unix was famously rewritten in the C programming language in 1973, which made it highly portable compared to earlier operating systems written in assembly.

Multiple choice
  1. sequencing

  2. alteration

  3. iteration

  4. all of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Structured programming is built on three fundamental control structures: sequence, selection (often called alteration), and iteration (loops).

Multiple choice
  1. Machine Language

  2. BASIC

  3. Any high level programming language

  4. Specific programming language

  5. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Computers operate at the hardware level using binary signals, which are represented by machine language. All other languages must be translated into machine language for the CPU to execute them.

Multiple choice
  1. binary language

  2. low-level language

  3. high-level language

  4. machine language

  5. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Assembly level is a low-level language.

Multiple choice
  1. Interpreter

  2. Application program

  3. Compiler

  4. Assembler

  5. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A compiler is a program that translates source code written in a high-level language into machine-readable object code. An interpreter executes code line-by-line without creating a separate object file.