logo

AQA A-Level Computer Science practice

Which statement best contrasts a local variable with a global variable?

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

Which statement best contrasts a local variable with a global variable?.

  1. A.A local variable can be used throughout the whole program, while a global variable can be used only inside one function.
  2. B.A local variable is available only within its defined local section, while a global variable is available from a wider part of the program.
  3. C.A local variable must contain text, while a global variable must contain a number.
  4. D.A local variable is created before a program starts, while a global variable is created only inside a function.

Answer and explanation

Concise answer

A local variable is available only within its defined local section, while a global variable is available from a wider part of the program.

Why this is correct

The key difference is scope. A local variable is restricted to the part of the program where it is defined, whereas a global variable can be accessed from a wider part of the program.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions