Ace the A Level Computer Science OCR 2025 – Code Your Way to Success!

Question: 1 / 400

What is the defining characteristic of a local variable?

A variable that can only be accessed within its own class

A variable that has a global scope and lifetime

A variable that can only be used in a specific function

A local variable is characterized by its scope, which is limited to the block of code or function in which it is declared. This means that it can only be accessed and utilized within that specific function, ensuring its existence is temporary and isolated. Once the function completes execution, the local variable is typically destroyed, and its value cannot be accessed outside of that context.

In contrast, options that describe a variable with a global scope or lifetime, or those that suggest it persists throughout the program's runtime, pertain to global variables or different types of storage, not local variables. Thus, identifying that a local variable can only be utilized within a specific function accurately captures its defining characteristic.

Get further explanation with Examzify DeepDiveBeta

A variable that exists for the duration of the program

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy