DigiBacc

Practice questions › IB Computer Science › Computer fundamentals › Translation
IB Computer Science · Computer fundamentals

Translation practice questions.

30 exam-style questions on Translation — topic A1.4 of Computer fundamentals in the IB Computer Science syllabus — with answers and explanations. Samples below; the full set is free with an account.

At a glance

About this topic

Syllabus code
A1.4
Subject
IB Computer Science
Topic
A1 · Computer fundamentals
Questions
30 with worked answers
Question types
10 multiple-choice questions · 6 flashcards · 5 fill-in-the-gap questions · 4 true/false questions · 3 matching tasks · 1 diagram task · 1 structured question
Try it

Sample questions on Translation

A developer changes one line in a large program and wants to see the effect immediately. Which is a genuine advantage of using an interpreter here?

  • The whole program is checked for errors before anything runs
  • No separate translation step is needed before testing
  • The translated program will execute faster than a compiled one
  • An executable file is produced that can be given to other users

Answer: No separate translation step is needed before testing

An interpreter translates and executes statement by statement, so the edited program can be run at once with no build step. The other options describe what a compiler provides, and interpreted code runs more slowly rather than faster.

In which order does a compiler carry out the stages of translation?

  • Syntax analysis, lexical analysis, code generation, semantic analysis
  • Semantic analysis, lexical analysis, syntax analysis, code generation
  • Lexical analysis, semantic analysis, syntax analysis, code generation
  • Lexical analysis, syntax analysis, semantic analysis, code generation

Answer: Lexical analysis, syntax analysis, semantic analysis, code generation

Characters must first be grouped into tokens, the tokens can then be checked against the grammar, meaning can only be checked once the structure is known, and instructions are generated last. Every stage consumes the output of the one before it.

A program has been compiled into object code and calls a routine from a mathematics library that was compiled separately. Which tool joins the two into a single executable file?

  • The lexical analyser
  • The assembler
  • The loader
  • The linker

Answer: The linker

The linker resolves the references between separately compiled modules and produces one executable. The loader only copies that finished file into primary memory at the moment it is run.

Which fault in a source program is detected by the syntax analysis stage rather than by the lexical analysis stage?

  • An identifier containing a character that the language does not allow
  • A closing bracket missing from an arithmetic expression
  • A number written with two decimal points in it
  • A string literal whose closing quotation mark is absent

Answer: A closing bracket missing from an arithmetic expression

Lexical analysis works symbol by symbol and can only object to something that cannot form a valid token at all. Unbalanced brackets become visible only when the parser tries to fit the whole sequence of tokens to the grammar.

A program is distributed as bytecode. Why can the same file be run on machines with different processors?

  • The processors of all modern machines understand bytecode directly
  • Bytecode contains only data, so no instructions have to be translated
  • Each machine runs a virtual machine that translates the bytecode
  • The bytecode is written in the source language of the program

Answer: Each machine runs a virtual machine that translates the bytecode

Bytecode is the output of a compiler aimed at an idealised machine, and the virtual machine on each platform turns it into the native instructions of that processor. Only the virtual machine has to be rewritten for a new processor, not the program.

A source program contains a statement that stores a string value in a variable that was declared to hold an integer. The statement is correctly punctuated and correctly formed. At which stage of compilation is the fault detected?

  • Lexical analysis
  • Syntax analysis
  • Semantic analysis
  • Optimisation and code generation

Answer: Semantic analysis

Lexical analysis only groups characters into tokens and syntax analysis only checks that the tokens form a legal structure, and this statement passes both. Meaning, including whether the types on the two sides of an assignment are compatible, is checked afterwards using the information the symbol table holds about each identifier.

That was 6 of 30 Translation questions.

Practise all 30 free
Exam tips

Command terms in this topic

Keep going

More topics in Computer fundamentals

All of Computer fundamentals →

30 Translation questions — free with an account. Spaced repetition, streaks and full exam simulations included.

Practise them free

This platform is independently developed and is not endorsed by, affiliated with, or sponsored by the International Baccalaureate Organization. “International Baccalaureate” and “IB” are registered trademarks of the IBO.