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
methods-oop
Methods (OOP)
What is a method?
-
Methods are fundamental in object-oriented programming (OOP) and are functions associated with objects or classes that define the behaviour and actions that objects can perform
-
There are two main types of methods:
-
A function
-
A function performs a task and returns a value
-
-
A procedure
-
A procedure performs a task buts does nor return a value
-
-
-
For example, there are many different types of aircraft which all differ in design, but all require a ‘take off’ and ‘landing’ method
-
An example of an aircraft class with both attributes and methods is shown below:

Example class for “aircraft” containing several methods
-
Each object that is created from the aircraft class will have:
-
A manufacturer value to determine the company that created the aircraft
-
A model name for the type of aircraft
-
A value for passenger capacity to determine how many people it can carry
-
A speed value to determine its maximum speed
-
-
Any objects that are created for the aircraft class also have access to the following Methods:
-
A take off method to get the plane airborne
-
A land method to land the plane safely
-
A bank left method to allow the plane to turn to the left
-
A bank right method to allow the plane to tur to the right
-
-
As you can imagine, for an aircraft there would be many more methods that could be implemented such emergency landing and altitude cruising actions
-
Once objects have been created, they can use the methods from within their class by using the dot (.) notation
-
As these methods are associated with objects, they are called instance methods
-
For example if an object has been created as below:
-
jumboJet = new aircraft (“Boeing”, ”747”, 416, 547)
-
-
It can use methods by doing the following:
-
Objectname.Methodname: -
For example:
jumboJet.Takeoff()
-
Examiner Tips and Tricks
-
In some OOP languages there are both instance methods and static methods
-
Instance methods
-
Instance methods are associated with individual instances (objects) of a class. They operate on the specific data and properties of an object (see above on the Jumbo Jet object example)
-
-
Static methods
-
Static methods are associated with a class itself and can be called without creating an instance (object) of the class
-
-
Public and private methods
-
When declaring methods, it is important to determine how they can be accessed:
|
Public Methods |
Private Methods |
|---|---|
|
Accessible and can be invoked by any code within the same class or from any external classes |
Private methods are only accessible within the same class and cannot be invoked by external code or other classes |
|
Changes to public methods may have an impact on other parts of the codebase, so they should be carefully designed, documented, and backward compatible whenever possible |
Changes to private methods have a localized impact since they are only used internally within the class, providing flexibility to modify or refactor them without affecting other parts of the program |
|
Public methods are used when you want to provide access to certain functionalities or behaviours of an object or class to other parts of your program |
Private methods are used when you have internal implementation details that should not be accessed or used by external code. They are meant to be used only within the class itself for organizing and managing the code internally |
Examiner Tips and Tricks
-
If a method does not specify the keyword public or private then its default value is set to public.
Worked Example
An object oriented system is implemented to organise further information about each worker’s attendance. Classes, objects, methods and attributes are used in this system.
State the meaning of a method
[1]
How to answer this question:
-
A clear definition of a method
-
The purpose of methods in OOP
Answer:
Example answer to get full marks:
A method is a function that belongs to a class and operates on its instance data, allowing objects to perform actions and behaviours. [1]
Responses