Lesson 4.1.1.13

4.1.1.13 Local and global variables Quiz: AQA Computer Science, Unit 1

20 questions

In partnership with Revision Ninja

Lesson 4.1.1.13, Local and global variables: 20 multiple choice questions for the AQA Computer Science (7517), Unit 1: Fundamentals of 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 term describes a variable accessible only within its declaring subroutine?

    • Pointer
    • Constant
    • Local variable
    • Global variable
  2. How does the scope of a local variable affect memory usage during program execution?

    • Memory remains allocated
    • Memory is doubled
    • Memory becomes static
    • Memory is released
  3. Where is a global variable declared?

    • Inside functions
    • Outside subroutines
    • Inside loops
    • Local stack
  4. What main risk is reduced by using local variables instead of global variables?

    • Stack overflow
    • Side effects
    • Syntax errors
    • Memory leaks
  5. Two subroutines declare a local variable named count. How do these variables interact?

    • Second overwrites first
    • They are independent
    • They share values
    • Syntax error occurs
  6. Which property primarily distinguishes a local variable from a global variable?

    • Scope
    • Memory size
    • Identifier length
    • Data type
  7. What happens to a local variable when its subroutine finishes executing?

    • It is destroyed
    • Made global
    • Moved to heap
    • Saved to disk
  8. What major issue can arise from updating global variables in multiple subroutines?

    • Increased compilation time
    • Difficult debugging
    • Syntax errors
    • Stack overflow
  9. Why should intermediate calculations inside a subroutine use local variables?

    • Makes variables global
    • Speeds up compilation
    • Frees memory automatically
    • Prevents parameter passing
  10. A function has a local variable x. A global x also exists. Which is accessed inside the function?

    • The local variable
    • Both variables
    • Neither variable
    • The global variable
  11. What error occurs if a subroutine tries to access another subroutine's local variable?

    • Scope error
    • Stack overflow
    • Type mismatch
    • Syntax error
  12. What key feature prevents local variables from colliding across different subroutines?

    • Global registry
    • Static linking
    • Heap sorting
    • Stack allocation
  13. What is achieved by passing data via parameters rather than using global variables?

    • Modular code design
    • Automatic data compression
    • Faster instruction cycles
    • Reduced stack memory
  14. A subroutine modifies a local variable sharing a name with a global variable. The global variable:

    • Is overwritten
    • Remains unchanged
    • Resets to zero
    • Is deleted
  15. What is the most appropriate use of a global variable?

    • Loop counter
    • Temporary result
    • Application-wide setting
    • Subroutine parameter
  16. What type of value might an uninitialised local variable hold?

    • Constant value
    • Unpredictable value
    • Null reference
    • Always zero
  17. Which term describes a variable accessible only within the subroutine declaring it?

    • Local scope
    • Global scope
    • Dynamic scope
    • Universal scope
  18. How should values be passed into a subroutine to avoid using global variables?

    • As return values
    • As global flags
    • As constants
    • As parameters
  19. Where is memory allocated for local variables when a subroutine is called?

    • On hard drive
    • On call stack
    • In heap memory
    • In global memory
  20. A local variable is initialised to 0 in a subroutine. What is its value at the start of a second call?

    • 1
    • 2
    • 0
    • Undefined

All AQA Computer Science quizzes