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

Study for the OCR GCSE Computer Science Exam. Prepare with flashcards, multiple choice questions, and hints. Get exam-ready with practical questions and answers!

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.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy