CCEA A-Level Software Systems Development CL4
Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures
Exception Handling and Managing Input and Output
Testing an Object Oriented Application
Graphical User Interface Objects and Events
Multiple Forms and Linking to Files
Designing, Testing and Evaluating an Event Driven Application
Reasons for Systems Development and Systems Methodologies
Managing Projects
Testing Strategies
Database Concepts and Entity Relationship Modelling
Normalisation and Structured Query Language
Project Management and the Systems Approach in Practice
Defining Requirements and Documenting the Design
Building a Desktop Solution with a Database
Testing and Evaluating the Solution
Defining Data: Types, Variables and Classes
Static variables in a class
- 3 things to know
- AS Unit 1
Overview
Static variable, static constant and static method.
What you need to know
Answer each one before you reveal it.
How does a static variable differ from an instance variable?
Why is a static variable normally accessed through the class name rather than through an object reference?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is a static variable?
Model answer
A static variable is a variable declared as belonging to the class itself rather than to any object, so a single copy is shared by every object of that class.
- 2
How many copies of a static variable exist, however many objects are created?
Model answer
Exactly one copy of a static variable exists, held with the class, no matter how many objects are created or whether any object exists at all.
- 3
How does a static variable differ from an instance variable?
Model answer
A static variable is shared by the whole class and holds one value for all objects, whereas each object receives its own instance variable and can hold a different value in it.
- 4
What are two realistic uses for a static variable?
Model answer
A static variable can count how many objects of a class have been created, and it can hold the next account number to be issued so that every object draws from one running source.
- 5
class Account { static int count = 0; Account() { count++; } } — what is the value of Account.count after three objects have been created?
Model answer
The value of Account.count is 3, because the single shared counter starts at 0 and the constructor adds one to that same counter each of the three times an object is made.
- 6
Why is a static variable normally accessed through the class name rather than through an object reference?
Model answer
A static variable belongs to the class, so using the class name makes clear that the value is shared and that no object is needed to reach it.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Defining Data: Types, Variables and Classes, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.