Computer-Science-A-level-Ocr
-
3-3-networks8 主题
-
3-2-databases7 主题
-
3-1-compression-encryption-and-hashing4 主题
-
2-5-object-oriented-languages7 主题
-
2-4-types-of-programming-language4 主题
-
2-3-software-development5 主题
-
2-2-applications-generation6 主题
-
2-1-systems-software8 主题
-
1-3-input-output-and-storage2 主题
-
1-2-types-of-processor3 主题
-
1-1-structure-and-function-of-the-processor1 主题
-
structuring-your-responses3 主题
-
the-exam-papers2 主题
-
8-2-algorithms-for-the-main-data-structures4 主题
-
8-1-algorithms10 主题
-
7-2-computational-methods11 主题
-
7-1-programming-techniques14 主题
-
capturing-selecting-managing-and-exchanging-data
-
entity-relationship-diagrams
-
data-normalisation
-
relational-databases
-
hashing
-
symmetric-vs-asymmetric-encryption
-
run-length-encoding-and-dictionary-coding
-
lossy-and-lossless-compression
-
polymorphism-oop
-
encapsulation-oop
-
inheritance-oop
-
attributes-oop
-
methods-oop
-
objects-oop
-
capturing-selecting-managing-and-exchanging-data
-
6-5-thinking-concurrently2 主题
-
6-4-thinking-logically2 主题
-
6-3-thinking-procedurally3 主题
-
6-2-thinking-ahead1 主题
-
6-1-thinking-abstractly3 主题
-
5-2-moral-and-ethical-issues9 主题
-
5-1-computing-related-legislation4 主题
-
4-3-boolean-algebra5 主题
-
4-2-data-structures10 主题
-
4-1-data-types9 主题
-
3-4-web-technologies16 主题
-
environmental-effects
-
automated-decision-making
-
computers-in-the-workforce
-
layout-colour-paradigms-and-character-sets
-
piracy-and-offensive-communications
-
analysing-personal-information
-
monitoring-behaviour
-
censorship-and-the-internet
-
artificial-intelligence
-
the-regulation-of-investigatory-powers-act-2000
-
the-copyright-design-and-patents-act-1988
-
the-computer-misuse-act-1990
-
the-data-protection-act-1998
-
adder-circuits
-
flip-flop-circuits
-
simplifying-boolean-algebra
-
environmental-effects
inheritance-oop
Inheritance (OOP)
What is inheritance?
-
Inheritance is a key concept in object-oriented programming (OOP) that allows a class to inherit the properties and behaviours (methods and attributes) of another class
-
Inheritance promotes code reuse by allowing derived classes to inherit and utilise the existing code from the base class. This avoids duplicating code and promotes better organization and maintainability
-
Inheritance establishes an “IS-A” relationship between the base class and the derived class
-
For example, if you have a base class called Vehicle and a derived class called Car, you can say that “a Car is a Vehicle.”
-
The car class inherits the properties and behaviours associated with being a vehicle
-
Inheritance involves two main entities:
-
The base class (also known as the parent class or superclass) and the derived class (also known as the child class or subclass)
-
The derived class inherits the characteristics of the base class, meaning it can access and use the methods and attributes defined in the base class
-

Example of a base class and derived classes
-
Base Class: The base class serves as the blueprint or template from which the derived class inherits
-
It defines common properties and behaviours that can be shared among multiple derived classes
-
-
Derived Class: The derived class inherits the attributes and methods of the base class
-
It can add additional attributes and methods
-
-
If a car object was to be created, it may have the following attributes:
-
Manufacturer – The company that makes the car
-
Make -The model of the car
-
Cost – The price of the car to purchase
-
IsInsured – Whether or not the car is insured
-
EngineCapacity – The size of the engine for the car
-
-
It may also have access to the following methods:
-
TurnEngineOn() – To start the car engine
-
TurnEngineOff() – To turn off the car engine
-
SteerLeft() – To turn the car to the left
-
SteerRight() – To steer the car to the left
-
GearChange() – To change the gear of the car
-
UnlockDoors() – To unlock the doors to the car
-
-
The above methods are only a select few and there could be many more added for extra functionality
-
In the following code, the super keyword is used in inheritance to refer to the superclass (Base class: Vehicles) and access its members (methods, attributes, or constructors) from within the subclass (Derived Class: Cars)
Worked Example
The classes office and house inherit from building.
Describe what is meant by inheritance with reference to these classes.
[2]
How to answer this question:
-
1 mark per bullet up to a maximum of 2 marks, e.g:
-
When the child/derived/subclass class office/house takes on attributes/methods…
-
… from building / parent/base/superclass/ class
-
Answer:
Example answer to get full marks:
When the derived classes “office” and “house” inherit attributes/methods [1] from the “building” base class, they gain access to the properties and behaviours defined in the “building” class. [1]
Responses