AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Fundamentals of Programming
Classes, Objects, Inheritance and Polymorphism
- 3 things to know
- Paper 1
Overview
Recall questions on classes, objects and instantiation, constructors, attributes and methods, encapsulation with getters and setters, inheritance and when to use it, overriding, and polymorphism.
What you need to know
Answer each one before you reveal it.
What is the difference between an attribute (property field) and a method?
What does a subclass inherit, and what can it do that its superclass cannot?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is a class?
Model answer
A template or blueprint that defines the methods and the property or attribute fields capturing the common behaviours and characteristics of a group of objects. It describes what any object of that kind will have and be able to do, but is not itself one of those objects. A class also acts as a data type, so variables can be declared of that class type.
- 2
What is an object?
Model answer
A particular instance of a class, existing in memory while the program runs, with its own values in the attribute fields the class defines and able to carry out the methods the class defines. Many objects can be created from one class, each holding its own data.
- 3
Distinguish between a class and an object, with an example.
Model answer
The class is the definition; the object is a thing made from it. A class Car might define attributes registration, make and mileage and methods start and service; the individual car with registration AB12 CDE is an object of that class. Changing that object's mileage affects only that object, whereas changing the class definition affects every object created from it. One class, any number of objects.
- 4
What is instantiation?
Model answer
The process of creating an object from a class. Memory is allocated for the new object, a constructor is run to set up its initial attribute values, and a reference to the object is assigned to a reference variable of the class type, through which the object is then used.
- 5
What is a constructor, and what is meant by an implicit and an explicit one?
Model answer
A constructor is the special method run automatically when an object is instantiated, whose job is to put the new object into a valid initial state. An explicit constructor is one the programmer writes, typically taking parameters so that initial attribute values can be supplied at creation. An implicit constructor is the default one the language supplies when none has been written, which creates the object with default attribute values.
- 6
What is the difference between an attribute (property field) and a method?
Model answer
An attribute is a data item belonging to an object, describing a characteristic of it, such as a car's mileage. A method is a subroutine belonging to the class, defining a behaviour the object can perform, such as service, and it can read and change that object's attributes. A class definition consists of both.
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 Fundamentals of Programming, 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.