Practise 28 exam-style questions on Translators: compilers and interpreters for OCR GCSE Computer Science (Paper 2). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with the Study Helper on hand if you get stuck.
28 questions
1–6 marks each
Instant marking
No sign-up needed
20 questions, marked as you go
Sample questions with model answers
Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.
Question 1
1 mark
State the type of translator that translates and executes a program one statement at a time.
Model answer
An interpreter
Explanation
An interpreter takes one line (statement) of source code, translates it into machine code, executes it, then moves on to the next line. A compiler instead translates the whole program before any of it runs. Remember the link: interpreter - line by line; compiler - all at once.
Mark scheme
1 mark
interpreter
Do not accept 'compiler', 'assembler' or 'translator' on its own.
Question 2
2 marks
A programmer shares an interpreted program with other people.
Explain why the programmer's code is less protected than if a compiled version had been shared.
Model answer
An interpreted program has to be given out as source code, because the interpreter on each user's computer needs it to translate the program. That means anyone who has it can read, copy or change the programmer's code.
Explanation
An interpreter needs the source code every time the program runs, so it has to be distributed with the program. A compiled program is shared as an executable file of machine code, which is very difficult for people to read or modify. This is one reason commercial software is usually compiled.
Mark scheme
1 mark
the source code itself must be given to the users (so that the interpreter can translate it on their computers)
1 mark
so users can read / copy / change / steal the code or ideas
Accept 'a compiled version is machine code, which is very hard for people to read or edit'. Do not accept 'interpreted programs have more viruses'.
Question 3
3 marks
Describe what a compiler does when it translates a program.
Model answer
A compiler translates the whole of the source code in one go into machine code (object code). If there are no errors, it produces an executable file that can be run without the compiler. If it finds errors, it lists them in an error report and does not produce an executable file.
Explanation
A compiler does all of the translation up front. The result is an executable file that runs quickly and can be given to users without the source code. If there are syntax errors, the compiler reports them together and no executable is made, so none of the program can run until the errors are fixed.
Mark scheme
1 mark
translates the whole program / all of the source code in one go (before it is run)
Max 3 marks in total.
1 mark
into machine code / object code
Accept 'binary'.
1 mark
produces an executable file (that can be run without the compiler)
1 mark
reports any errors found (in an error report) at the end of translation / no executable is produced if there are errors
Do not accept 'translates line by line' or 'runs each line as it translates' (an interpreter).
Question 4
4 marks
Explain two drawbacks of using a compiler while a program is still being developed and tested.
Model answer
The whole program has to be recompiled every time the programmer makes a change, and for a large program this can take a long time, which slows down testing. Errors are only reported once the whole program has been translated, so no part of the program can be run and tested until every syntax error has been fixed.
Explanation
During development a programmer changes and re-runs code many times. With a compiler, every change means recompiling, and nothing runs until the whole program is free of syntax errors. An interpreter suits this stage better because it can run code immediately and stops at each error in turn.
Mark scheme
1 mark
the whole program must be recompiled after every change
Max 4 marks: up to 2 drawbacks, each worth 1 mark for the drawback and 1 mark for its explanation.
1 mark
...which can take a long time, slowing down testing / development
1 mark
errors are only reported after the whole program has been translated
1 mark
...so no part of the program can be run / tested until every syntax error is fixed
1 mark
the compiler may produce a long list of errors at once
1 mark
...which can be harder to work through than one error at a time / one mistake may cause several error messages
Do not accept 'compiled programs run slowly'.
Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.
Ctrl + Enter to check
Study HelperHints first, answers after you try
Stuck on this one? Ask for a hint and I’ll point you in the right direction, without giving the answer away. Once you’ve checked your answer, I’ll show you how the marks are awarded.