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.
The 20 questions
-
Which basic programming construct executes statements sequentially, one after the other?
- Selection
- Iteration
- Recursion
- Sequence
-
Which programming construct uses a condition to determine which branch of code to run?
- Selection
- Iteration
- Sequence
- Recursion
-
Which type of loop executes a block of code a predetermined number of times?
- Infinite loop
- Recursive loop
- Condition-controlled
- Count-controlled
-
What essential component of a recursive function stops it from calling itself indefinitely?
- Stack frame
- General case
- Global variable
- Base case
-
Where are return addresses and local variables stored during nested recursive calls?
- Heap memory
- Data segment
- Call stack
- Register file
-
What happens to a local variable when its function finishes executing?
- Globalised
- Retained
- Deallocated
- Paused
-
What type of scope allows a variable to be accessed from any function in a programme?
- Global scope
- Block scope
- Dynamic scope
- Local scope
-
When passing a parameter by value, what does the subroutine actually receive?
- A local copy
- The original variable
- The memory address
- A reference pointer
-
When passing a parameter by reference, what does the subroutine receive?
- A local copy
- The memory address
- The return value
- A duplicate constant
-
Which statement best describes a WHILE loop compared to a REPEAT UNTIL loop?
- Pre-condition loop
- Post-condition loop
- Unconditional loop
- Count-controlled loop
-
What error occurs when a recursive function fails to reach its base case?
- Stack overflow
- Type error
- Syntax error
- Null pointer
-
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
-
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
-
Which programming construct is represented by a REPEAT UNTIL loop structure?
- Post-condition iteration
- Count-controlled iteration
- Pre-condition iteration
- Selection
-
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
-
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
-
A procedure alters a parameter and changes the caller's argument. How was the parameter passed?
- By reference
- By assignment
- By constant
- By value
-
Which variable lifetime lasts for the entire duration of a programme's execution?
- Loop counter
- Parameter
- Local variable
- Global variable
-
What side effect can excessive use of global variables introduce into software development?
- Infinite looping
- Stack overflow errors
- Syntax compilation failure
- Unwanted data modification
-
What is the minimum number of times a WHILE loop body will execute?
- Infinite times
- Zero times
- One time
- Two times
Related quizzes
- Modularity, parameter passing, IDEs and object-oriented techniques Quiz · 2.2.1b · 20 questions
- Problem recognition, decomposition, divide and conquer, abstraction Quiz · 2.2.2a · 20 questions
- Backtracking, data mining, heuristics, performance modelling, pipelining, visualisation Quiz · 2.2.2b · 20 questions
- Processor components: ALU, control unit, registers and buses Quiz · 1.1.1a · 20 questions
- Operating systems and memory management Quiz · 1.2.1a · 20 questions
- Compression, encryption and hashing Quiz · 1.3.1 · 20 questions
- Primitive data types and binary number representation Quiz · 1.4.1a · 20 questions
- Data Protection Act 1998 and Computer Misuse Act 1990 Quiz · 1.5.1a · 20 questions
- The nature and need for abstraction and abstract models Quiz · 2.1.1 · 20 questions
- Algorithm design, suitability, efficiency and Big O notation Quiz · 2.3.1a · 20 questions