OOP Basics I Flashcards
Learn OOP basics.
What are constants?
Constants are unchangeable public properties in a class.
$this is available when…
…a method is called from within an object context.
In the class context, it is possible to create a new object with…
new self and new parent.
What’s the difference between passing by value and passing by reference?
When you pass by value, you are making a copy. Passing by reference makes a new pointer to the original value.
A class can inherit from how many classes?
1
How can you override inherited methods and properties?
By redeclaring them with the same name defined in the parent class.
What does the ‘final’ keyword do?
It prevents child classes from overriding a method.
How do you access a parent’s overridden methods or properties in a child class?
By referencing them with parent::
When overriding methods, the parameter signature should…
…stay the same (unless it is the constructor).
What is the difference between $this and self?
Inside a class definition, $this refers to the current object, while self refers to the current class.
What is a property?
A class member variable.
How do you autoload classes?
Define an __autoload function.
Where can public class members be accessed?
Everywhere.
Where can protected class members be accessed?
Within the class itself, and by inherited and parent classes.
Where can private class members be accessed?
Only by the class that defines the member.