• Practice
  • About 12 min
  • 5 practice questions

Concept and terminology traps: translators, data structures, searching, sorting and OOP

Answer definition-style questions quickly by recalling one distinguishing fact for each pair of look-alike programming terms.

If something looks wrong, please tell us.

Many programming questions are not traces but definitions. The options are built from look-alike terms, so the winning habit is to remember one distinguishing fact for each pair. This lesson collects those facts and then shows how to use them to eliminate options.

Pairs and their distinguishing fact

Look-alike pairs
PairDistinguishing fact
Compiler / interpreterA compiler translates the whole program first; an interpreter translates and runs it line by line
Source code / object codeSource code is written by people; object code is the translated machine code
Syntax error / logical errorSyntax error breaks the grammar rules and stops translation; logical error runs but gives wrong results
Runtime error / logical errorA runtime error stops the program while it runs, for example dividing by zero
Stack / queueStack is last in, first out; queue is first in, first out
Linear / binary searchBinary search needs sorted data and halves the range each time
Bubble / selection sortBubble swaps neighbours; selection picks the smallest each time
Local / global variableLocal exists only in its function; global is visible everywhere
Class / objectA class is the blueprint; an object is one thing built from it
Algorithm / programAn algorithm is the plan in steps; a program is the plan written in a programming language
Pseudocode / flowchartPseudocode is words; a flowchart is a diagram

Programming terms in one line

  • Variable: a named memory location whose value can change. Constant: a value that does not change.
  • Function: a named, reusable block of code; parameter: an input to it; return value: what it gives back.
  • Loop: repeats steps; selection: chooses a path; sequence: steps in order.
  • Debugging: finding and fixing errors. Bug: an error in a program.
  • High-level language: close to human language and independent of the machine; low-level language: close to the machine.

Worked example 1: eliminate

Which of these is NOT a feature of a compiler? (a) Translates the entire program, (b) Produces object code, (c) Executes the program line by line, (d) Reports syntax errors. Only (c) describes an interpreter, so (c) is the answer.

Worked example 2: classify the error

A program is meant to print the average of three numbers but it adds them and divides by 2. It runs and prints a number, but the number is wrong. A program that runs and gives wrong output has a logical error, because the grammar is fine and nothing stops it. If a bracket were missing, it would be a syntax error; if it tried to divide by an input of 0, a runtime error.

Worked example 3: structure from the story

"Customers are served in the order they arrive." This is first in, first out: a queue. "The last page visited is the first one the Back button returns to." This is last in, first out: a stack. "A list that must be sorted before it can be halved repeatedly" describes binary search.

For each pair, remember one fact that only one member of the pair has.

Common traps

  • Saying the interpreter creates a separate object file for the whole program.
  • Calling every wrong result a syntax error.
  • Confusing a class with an object.
  • Forgetting that binary search needs a sorted list.

Check your understanding

  1. 1. Which translator executes a program statement by statement?

    1. Compiler
    2. Assembler
    3. Interpreter
    4. Preprocessor
    Show answer

    Answer: C. An interpreter translates and runs one statement at a time.

  2. 2. A program runs to the end but prints a wrong answer. This is a

    1. Syntax error
    2. Runtime error
    3. Compile-time error
    4. Logical error
    Show answer

    Answer: D. Wrong results from a program that runs normally indicate a logical error.

  3. 3. Which structure is first in, first out?

    1. Stack
    2. Array
    3. Queue
    4. Tree
    Show answer

    Answer: C. A queue removes the item that arrived first.

  4. 4. A class is best described as:

    1. A blueprint for objects
    2. A running program copy
    3. A name for a variable
    4. A kind of program loop
    Show answer

    Answer: A. A class is a blueprint or template from which objects are made.

  5. 5. Which search method halves the range on each step?

    1. Linear search
    2. Binary search
    3. Random search
    4. Serial search
    Show answer

    Answer: B. Binary search divides a sorted list in half at every comparison.

Privacy · Terms · Refunds · Delivery