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.
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?
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?
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?
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?
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?
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?
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 freeDistinguishAO2 · 2–4 marks
Make the difference clear for BOTH terms — a definition of one of them is only half an answer.
ExplainAO2 · 2–4 marks
Give reasons or causes: say what happens AND why, linking each step with 'because' or 'so that'.
OutlineAO1 · 1–2 marks
A brief account or summary: the main points in two or three sentences, no evaluation.
30 Translation questions — free with an account. Spaced repetition, streaks and full exam simulations included.
Practise them freeThis 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.