1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Private vs Public
Controls who can access something inside a class.
Private - only the class can directly access it and is used to protect data
Public - All other code can access it
Encapsulation
Putting data and the functions that control that data together inside a class, while hiding/protecting the data.
Getters
A getter gets/returns the value of a private variable
Setters
A setter changes the value of a private variable
Inspectors
An inspector is a function that looks at/gets information from an object without changing it
Mutators
A mutator is a function that changes the object’s data/state.
Constructors
A special function that runs automatically when an object is created.
Important constructor rules
A constructor:
Has the same name as the class
Has no return type
Runs automatically when an object is created
Facilitators
Facilitators generally mean functions that perform an operation or provide some service for the object, rather than simply getting or setting a value
Static
The static keyword means something belongs to the class itself rather to each individual object