Objects
Computer Science: OCR A Level, topic 2.4.10
Objects
Objects are made from classes.

Creating an Object
- Objects are created from classes.
- To create an object we use the keyword
newand the name of the class: MyClass myObj = new MyClass();

Accessing attributes
- If an attribute of an object is public, then it can be accessed from outside the class.
- Object attributes are accessed using dot notation:
int attr = myObj.attr;

Calling methods
- If a method of an object is public, then it can be accessed from outside the class.
- Object methods are accessed using dot notation:
myObj.doSomething();
Test yourself on Objects
Which keyword is used to create an object?
How would the attribute
nameof the classmyClassbe accessed?