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
Objects, Classes and Data Structures
Arrays of objects
- 3 things to know
- AS Unit 1
Overview
Declaring an array whose elements are objects, why every element starts empty, creating each object before it is used, and the error raised by reaching through an element that holds nothing.
What you need to know
Answer each one before you reveal it.
A library program declares an array of 200 Book references but currently holds only 40 books. What is the cost of that decision?
What has to be done to an element of an array of objects before it can be used?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What does the statement Student[] group = new Student[3]; create?
Model answer
The statement creates an array able to hold three Student references, and no Student object exists yet because every element starts as null.
- 2
A program executes Student[] group = new Student[3]; and then System.out.println(group[0]);. What is printed?
Model answer
The statement prints null, because creating the array reserves three reference slots and sets each of them to refer to no object at all.
- 3
What has to be done to an element of an array of objects before it can be used?
Model answer
Each element must be given an object of its own, as in group[0] = new Student("Aoife");, before any method can be called through that element.
- 4
A program executes Student[] group = new Student[3]; and then group[0].getName();. What happens?
Model answer
The program stops with a null pointer exception at run time, because element 0 still refers to no object and there is nothing on which getName could be called.
- 5
What does each element of an array of objects actually store?
Model answer
Each element stores a reference to an object held elsewhere in memory rather than the object itself.
- 6
Contrast what is stored in an array of integers with what is stored in an array of objects.
Model answer
An array of a simple type holds the values themselves inside the array, while an array of objects holds references and the objects sit separately in memory.
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 Objects, Classes and Data Structures, 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.