Prepare for the A Level Computer Science OCR Exam with engaging quiz questions and interactive flashcards. Get ready to excel in your exam with comprehensive study materials designed to bolster your knowledge and confidence.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which type of variable is accessible throughout the entire program?

  1. Local Variable

  2. Temporary Variable

  3. Global Variable

  4. Instance Variable

The correct answer is: 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.