Oxford, Cambridge and RSA (OCR) GCSE Computer Science Practice Exam

Disable ads (and more) with a premium pass for a one time $4.99 payment

Question: 1 / 340

What is the name of a variable that is accessible throughout the entire program?

Local variable

Instance variable

Global variable

A variable that is accessible throughout the entire program is referred to as a global variable. This means that it can be accessed and modified from any part of the code, regardless of the context in which it is used. Global variables are declared outside of any functions or blocks, making their scope universal across the entire program.

In contrast, a local variable is limited to the block or function in which it is defined and cannot be accessed outside of that scope. An instance variable typically relates to object-oriented programming, where it is used to represent attributes that are specific to an object, and it is only accessible through the instance of that class. A static variable, on the other hand, retains its value across function calls but is still associated with a particular scope, often tied to class or function rather than being universally accessible.

Thus, the defining characteristic of a global variable is its ability to be accessed from anywhere in the program, making it the correct answer in this context.

Get further explanation with Examzify DeepDiveBeta

Static variable

Next

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy