A Level Computer Science OCR Test 2025 – 400 Free Practice Questions to Pass the Exam

Question: 1 / 400

What is the defining feature of a Local Variable?

It can be used anywhere in the program

It is only accessible within the function or block it is defined

The defining feature of a Local Variable is that it is only accessible within the function or block in which it is defined. This means that the variable's scope is limited to that specific function, and it cannot be accessed or modified from outside that function. This encapsulation allows for greater control over data and helps to prevent unintended interference between different parts of the program, as each function can have its own local variables that do not affect others.

In contrast, global variables are accessible from anywhere in the program, which would be why the first option would not apply. The third option points to the characteristic of global variables as well, as local variables do not persist throughout the entire program; their lifetime is confined to the execution of the function in which they are created. The fourth option inaccurately suggests that local variables share values across different functions, while in reality, they are unique to their defining context.

Get further explanation with Examzify DeepDiveBeta

It persists throughout the entire program

It holds values that are shared across different functions

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy