Lesson 2.2.1a

2.2.1a Programming constructs, recursion and variable scope Quiz: OCR Computer Science, Unit 7

20 questions

In partnership with Revision Ninja

Lesson 2.2.1a, Programming constructs, recursion and variable scope: 20 multiple choice questions for the OCR Computer Science (H446), Unit 7: Problem solving and programming, written with Revision Ninja.

Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.

Host this setFree Play

The 20 questions

  1. Which basic programming construct executes statements sequentially, one after the other?

    • Selection
    • Iteration
    • Recursion
    • Sequence
  2. Which programming construct uses a condition to determine which branch of code to run?

    • Selection
    • Iteration
    • Sequence
    • Recursion
  3. Which type of loop executes a block of code a predetermined number of times?

    • Infinite loop
    • Recursive loop
    • Condition-controlled
    • Count-controlled
  4. What essential component of a recursive function stops it from calling itself indefinitely?

    • Stack frame
    • General case
    • Global variable
    • Base case
  5. Where are return addresses and local variables stored during nested recursive calls?

    • Heap memory
    • Data segment
    • Call stack
    • Register file
  6. What happens to a local variable when its function finishes executing?

    • Globalised
    • Retained
    • Deallocated
    • Paused
  7. What type of scope allows a variable to be accessed from any function in a programme?

    • Global scope
    • Block scope
    • Dynamic scope
    • Local scope
  8. When passing a parameter by value, what does the subroutine actually receive?

    • A local copy
    • The original variable
    • The memory address
    • A reference pointer
  9. When passing a parameter by reference, what does the subroutine receive?

    • A local copy
    • The memory address
    • The return value
    • A duplicate constant
  10. Which statement best describes a WHILE loop compared to a REPEAT UNTIL loop?

    • Pre-condition loop
    • Post-condition loop
    • Unconditional loop
    • Count-controlled loop
  11. What error occurs when a recursive function fails to reach its base case?

    • Stack overflow
    • Type error
    • Syntax error
    • Null pointer
  12. If a local variable shares a name with a global variable, which takes precedence inside the function?

    • The global variable
    • The local variable
    • Neither variable
    • The first declared
  13. What is the output of func(3) for func(n): IF n==1 RETURN 1 ELSE RETURN n * func(n-1)?

    • 24
    • 6
    • 2
    • 3
  14. Which programming construct is represented by a REPEAT UNTIL loop structure?

    • Post-condition iteration
    • Count-controlled iteration
    • Pre-condition iteration
    • Selection
  15. Why might an iterative solution be preferred over a recursive solution for memory efficiency?

    • Uses less stack
    • Uses fewer registers
    • Avoids CPU usage
    • Allocates more heap
  16. What name is given to the section of recursion that reduces the problem towards the base case?

    • Recursive step
    • Loop condition
    • Stack frame
    • Base case
  17. A procedure alters a parameter and changes the caller's argument. How was the parameter passed?

    • By reference
    • By assignment
    • By constant
    • By value
  18. Which variable lifetime lasts for the entire duration of a programme's execution?

    • Loop counter
    • Parameter
    • Local variable
    • Global variable
  19. What side effect can excessive use of global variables introduce into software development?

    • Infinite looping
    • Stack overflow errors
    • Syntax compilation failure
    • Unwanted data modification
  20. What is the minimum number of times a WHILE loop body will execute?

    • Infinite times
    • Zero times
    • One time
    • Two times

All OCR Computer Science quizzes