Classes
Computer Science: OCR A Level, topic 2.4.9
Classes
A class is a blueprint for creating objects.

What is a class?
- A class is a blueprint for creating an object.
- One class will often represent one type of real-world object.
- For example: in a snooker game you might have a 'Ball' class.

What is inside a class?
- A class contains two main components:
- Attributes: these are variables which describe the object.
- Methods: these are subroutines which allow the object to perform actions.

Classes in Java
- Classes have different levels of visibility.
- In Java, classes are created using the
classkeyword. - These classes can be made public (can be used in any part of the program) using the
public classkeywords. - The image above shows a Java class.
Test yourself on Classes
Which of these statements are true about classes?
Which keyword is used to create a class in Java?