Object Oriented Concept - Study Mode

[#1] What will be the output if a protected method is given as argument to the function method_exist()?
Correct Answer

(D) True

Explanation

Solution: method_exists() returns true for private and protected methods as well as for public ones. Remember that the fact that a method exists does not mean that it will be callable.

[#2] Which one of the following function should I use to find the parent class of a class?
Correct Answer

(A) get_parent_class()

Explanation

Solution: The class functions also allow us to chart inheritance relationships.This function requires either an object or a class name, and it returns the name of the superclass, if any. If no such class exists, that is, if the class we are testing does not have a parent, then the function returns false.

[#3] Which class accepts a class name or an object reference and returns an array of interface name?
Correct Answer

(A) class_implements()

Explanation

Solution: is_subclass_of() will tell you only about class inheritance relationships. It will not tell you that a class implements an interface.

[#4] Object-oriented code tries to minimize dependencies by moving responsibility for handling tasks away from _______ and toward the objects in the system.
Correct Answer

(B) client code

Explanation

Solution: Procedural code takes the form of a sequential series of commands and method calls. The controlling code tends to take responsibility for handling differing conditions. This top-down control can result in the development of duplications and dependencies across a project. Object-oriented code tries to minimize these dependencies by moving responsibility for handling tasks away from client code and toward the objects in the system.

[#5] Placing a static method for generating _______ objects in the ________ class is convenient.
Correct Answer

(A) child parent

Explanation

Solution: Such a design decision does have its own consequences, however.