A Level Computer Science OCR Practice Exam 2025 - Free Practice Questions and Study Guide

Question: 1 / 400

Which type of variable is accessible throughout the entire program?

Local Variable

Temporary Variable

Global Variable

The correct answer is global variable. A global variable is defined outside of any function or method, making it accessible from any part of the program, regardless of where it is referenced. This means that once a global variable is declared, any function or block of code can read or modify its value, facilitating communication and data sharing across different scopes within the program.

Local variables, on the other hand, are confined to the function or block in which they are declared, limiting their accessibility and lifetime. They cannot be accessed outside of that specific scope. Temporary variables typically refer to variables used for brief calculations or storage within a method and generally fall under the category of local variables. Instance variables are tied to a specific instance of a class in object-oriented programming and can also have restricted access depending on where they are defined, either within the context of the object or potentially accessible through methods of that object.

Overall, global variables provide a means to maintain state or manage data across various functions in a program, hence their designation as accessible throughout the entire program.

Get further explanation with Examzify DeepDiveBeta

Instance Variable

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy