InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which magic method is used to implement overloading in PHP?(a) __call(b) __invoke(c) __wakeup(d) __unsetI have been asked this question by my college professor while I was bunking the class.This intriguing question originated from Advanced Object-Oriented PHP topic in division Object-Oriented PHP of PHP |
|
Answer» The correct ANSWER is (a) __call |
|
| 2. |
Which feature allows us to call more than one method or function of the class in single instruction?(a) Typecasting(b) Method Including(c) Method adding(d) Method chainingThis question was posed to me during an interview.Question is from Advanced Object-Oriented PHP topic in division Object-Oriented PHP of PHP |
|
Answer» Right option is (d) Method chaining |
|
| 3. |
If your object must inherit behavior from a number of sources you must use a/an(a) Interface(b) Object(c) Abstract class(d) Static classThe question was asked in class test.Question is from Advanced Object-Oriented PHP topic in chapter Object-Oriented PHP of PHP |
|
Answer» Correct answer is (a) INTERFACE |
|
| 4. |
Which method is used to tweak an object’s cloning behavior?(a) clone()(b) __clone()(c) _clone(d) object_clone()This question was posed to me in unit test.Question is taken from Advanced Object-Oriented PHP in chapter Object-Oriented PHP of PHP |
|
Answer» Right CHOICE is (b) __clone() |
|
| 5. |
If one intends to create a model that will be assumed by anumber of closely related objects, which class must be used?(a) Normal class(b) Static class(c) Abstract class(d) InterfaceI got this question in an international level competition.This is a very interesting question from Advanced Object-Oriented PHP in chapter Object-Oriented PHP of PHP |
|
Answer» Correct choice is (c) Abstract class |
|
| 6. |
Which one of the following is the right way to clone an object?(a) _clone(targetObject);(b) destinationObject = clone targetObject;(c) destinationObject = _clone(targetObject);(d) destinationObject = clone(targetObject);This question was addressed to me in exam.I'm obligated to ask this question of Advanced Object-Oriented PHP topic in chapter Object-Oriented PHP of PHP |
|
Answer» Correct choice is (b) destinationObject = clone targetObject; |
|
| 7. |
Which version of PHP introduced the advanced concepts of OOP?(a) PHP 4(b) PHP 5(c) PHP 5.3(d) PHP 6I had been asked this question during an internship interview.This question is from Advanced Object-Oriented PHP in chapter Object-Oriented PHP of PHP |
|
Answer» The correct choice is (b) PHP 5 |
|
| 8. |
Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?(a) protected(b) final(c) static(d) privateThe question was asked in exam.This intriguing question originated from Basics of Object-Oriented PHP- 2 in division Object-Oriented PHP of PHP |
|
Answer» The correct answer is (c) static |
|
| 9. |
Which keyword is used to refer to properties or methods within the class itself?(a) private(b) public(c) protected(d) $thisThis question was posed to me in an interview for internship.This question is from Basics of Object-Oriented PHP- 2 in section Object-Oriented PHP of PHP |
|
Answer» Correct choice is (d) $this |
|
| 10. |
Which one of the following keyword is used to inherit our subclass into a superclass?(a) extends(b) implements(c) inherit(d) includeI got this question in semester exam.This question is from Basics of Object-Oriented PHP- 2 topic in section Object-Oriented PHP of PHP |
|
Answer» The correct option is (a) extends |
|
| 11. |
Which one of the following functions is used to determine object type?(a) obj_type()(b) type()(c) is_a()(d) is_obj()The question was posed to me by my college director while I was bunking the class.I want to ask this question from Basics of Object-Oriented PHP- 2 topic in division Object-Oriented PHP of PHP |
|
Answer» The correct OPTION is (c) is_a() |
|
| 12. |
Which one of the following functions is used to determine whether a class exists?(a) exist()(b) exist_class()(c) class_exist()(d) __exist()This question was addressed to me by my college professor while I was bunking the class.My enquiry is from Basics of Object-Oriented PHP- 2 in chapter Object-Oriented PHP of PHP |
|
Answer» RIGHT CHOICE is (c) class_exist() To elaborate: The class_exist() FUNCTION returns true or false according to whether the CLASS exists within the currently EXECUTING script content. |
|
| 13. |
Which method scope prevents a method from being overridden by a subclass?(a) Abstract(b) Protected(c) Final(d) StaticI got this question in an online interview.The origin of the question is Basics of Object-Oriented PHP- 2 in chapter Object-Oriented PHP of PHP |
|
Answer» The correct ANSWER is (C) Final |
|
| 14. |
Which version of PHP introduced the instanceof keyword?(a) PHP 4(b) PHP 5(c) PHP 5.3(d) PHP 6I had been asked this question during an interview for a job.Question is from Basics of Object-Oriented PHP- 2 topic in portion Object-Oriented PHP of PHP |
|
Answer» Correct answer is (B) PHP 5 |
|
| 15. |
PHP recognizes constructors by the name _________(a) classname()(b) _construct()(c) function _construct()(d) function __construct()This question was addressed to me in my homework.This is a very interesting question from Basics of Object-Oriented PHP- 2 topic in section Object-Oriented PHP of PHP |
|
Answer» The correct OPTION is (d) function __construct() |
|
| 16. |
Which one of the following is the right way to invoke a method?(a) $object->methodName();(b) object->methodName();(c) object::methodName();(d) $object::methodName();This question was addressed to me by my school teacher while I was bunking the class.This intriguing question comes from Basics of Object-Oriented PHP- 1 topic in portion Object-Oriented PHP of PHP |
|
Answer» Correct choice is (a) $OBJECT->methodName(); |
|
| 17. |
Which one of the following is the right way to call a class constant, given that the class is mathFunction?(a) echo PI;(b) echo mathFunction->PI;(c) echo mathFunction::PI;(d) echo mathFunction=PI;I got this question during an online exam.My doubt stems from Basics of Object-Oriented PHP- 1 topic in section Object-Oriented PHP of PHP |
|
Answer» RIGHT answer is (C) ECHO mathFunction::PI; To elaborate: The SCOPE Resolution Operator “::” is a token that allows access to static, constant, and overridden properties or methods of a CLASS. |
|
| 18. |
Which one of the following is the right way to define a constant?(a) constant PI = “3.1415”;(b) const $PI = “3.1415”;(c) constant PI = ‘3.1415’;(d) const PI = ‘3.1415’;I had been asked this question by my school teacher while I was bunking the class.I need to ask this question from Basics of Object-Oriented PHP- 1 topic in section Object-Oriented PHP of PHP |
|
Answer» Correct answer is (d) CONST PI = ‘3.1415’; |
|
| 19. |
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?(a) $obj = new $foo;(b) $obj = new foo;(c) $obj = new foo ();(d) obj = new foo ();The question was posed to me in homework.This intriguing question comes from Basics of Object-Oriented PHP- 1 topic in division Object-Oriented PHP of PHP |
|
Answer» Correct answer is (c) $obj = NEW foo (); |
|
| 20. |
Which one of the following property scopes is not supported by PHP?(a) friendly(b) final(c) public(d) staticThe question was posed to me in an interview.Question is taken from Basics of Object-Oriented PHP- 1 in section Object-Oriented PHP of PHP |
|
Answer» Right option is (a) friendly |
|
| 21. |
The practice of creating objects based on predefined classes is often referred to as ______________(a) class creation(b) object creation(c) object instantiation(d) class instantiationThis question was addressed to me in an online quiz.I want to ask this question from Basics of Object-Oriented PHP- 1 topic in chapter Object-Oriented PHP of PHP |
|
Answer» Correct ANSWER is (d) class INSTANTIATION |
|
| 22. |
Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?(a) Abstraction(b) Polymorphism(c) Inheritance(d) DifferentialI have been asked this question in an international level competition.The doubt is from Basics of Object-Oriented PHP- 1 topic in chapter Object-Oriented PHP of PHP |
|
Answer» Correct choice is (b) Polymorphism |
|
| 23. |
The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________(a) Polymorphism(b) Inheritance(c) Encapsulation(d) AbstractionI have been asked this question in an interview for internship.The query is from Basics of Object-Oriented PHP- 1 topic in portion Object-Oriented PHP of PHP |
|
Answer» Correct CHOICE is (C) ENCAPSULATION |
|