Karteikarten
OOP

Karten in diesem Stapel (15)
- 1How many times is a static class instantiated?Once
- 2Call a static class from a parent

- 3What's the point of static classes?1. The state of static class doesn't change
2. Can be called globally - 4Whats' different about read-only classes?All their properties act like read-only properties.
- 5What's different about read-only properties?1. They cannot have a default value.
2. They can only be assigned a value once.
3. Can only be set by a method of their class even if they are public
4. They cannot be unset. - 6Can a child redeclare a method or constant of its parent?Yes, if the parent method is not "final".
- 7What class type cannot have a child?A "final" class
- 8Can a child remove an argument from a redeclared method?No, a child can only add arguments when redeclaring a method
- 9Is this valid in PHP? $result = $repository?->getUser(5)?->name;Yes, PHP has a null safe operator
- 10How do you access a constant in a class?::
- 11What is encapsulation?Putting things in a class. This ...
1. Creates Abstraction
2. Controls access ( private, public, etc )
3. Hides Data - 12What's the difference between protected and private?Protected -> Accessible from code within class or child
Private -> Only accessible from code within class - 13What is an abstract class?A class where is functions are declared but not implemented
- 14How is a abstract class different from a interface?1. interfaces don't have public functions with bodies.
2. Interfaces don't have properties
3. A class can implement multiple interfaces - 15Trade-offs of using traits vs dependency injection?1. Less boilerplate
2. "Inherit" multiple classes
3. Trait properties, functions become apart of the class its used in.
Informationen
- Beschreibung
- 1 PHP Karteikarten am OOP, erstellt von Kevin Nelson am 08/05/2024.
- Erstellt von
- Kevin Nelson
- Aufrufe
- 0
- Bewertung