PHP Object Oriented Quiz (original) (raw)
How do you create an object of a class named Car
?
What is the purpose of a constructor in PHP classes?
- To define access modifiers
Which magic method acts as a destructor in PHP?
What does the public
access modifier do?
- Makes properties accessible only within the class
- Makes properties accessible within the class and subclasses
- Makes properties accessible from anywhere
- Hides properties completely
Which modifier restricts property access to the class itself?
How do you declare a namespace called MyApp
?
What is the purpose of namespaces in PHP?
- Group related classes and avoid name conflicts
Which keyword is used to include a trait in a class?
- A mechanism for code reuse across unrelated classes
There are 10 questions to complete.
Take a part in the ongoing discussion