K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which PHPUnit annotation runs a method before each test? (A) @before (B) @setup (C) @init (D) @start 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (A) @before Explanation: @before runs before each test.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which OOP principle restricts direct access to class data? (A) Inheritance (B) Encapsulation (C) Polymorphism (D) Abstraction 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) Encapsulation Explanation: Encapsulation hides internal data using access modifiers.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which access modifier allows access only within the same class? (A) public (B) protected (C) private (D) static 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (C) private Explanation: private members are accessible only inside the class.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which keyword is used to implement an interface? (A) extends (B) implements (C) interface (D) uses 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) implements Explanation: implements keyword is used with interfaces.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which keyword allows accessing parent class methods? (A) this (B) parent (C) self (D) static 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) parent Explanation: parent:: is used to access parent class members.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which magic method is called when an object is converted to string? (A) __string() (B) __toString() (C) __convert() (D) __print() 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) __toString() Explanation: __toString() defines string representation.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which magic method is called when invoking inaccessible methods? (A) __get() (B) __call() (C) __invoke() (D) __set() 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) __call() Explanation: __call() handles calls to inaccessible methods.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which design pattern ensures a class has only one instance? (A) Factory (B) Observer (C) Singleton (D) Strategy 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (C) Singleton Explanation: Singleton restricts class instantiation.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which design pattern provides an interface for creating objects? (A) Singleton (B) Factory (C) Decorator (D) Adapter 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) Factory Explanation: Factory abstracts object creation.
K Kanak Sharma 🎓 Tutor III ⭐ 5.92K Points 📊 PHP Q. Which design pattern allows behavior to be added dynamically? (A) Adapter (B) Decorator (C) Facade (D) Observer 👁️ Show Answer 💬 Discuss 🔗 Share ✅ Correct Answer: (B) Decorator Explanation: Decorator adds responsibilities dynamically.