Object Oriented Concept - Study Mode

[#91] Which one of the following will you use to check the class of an object?
Correct Answer

(D) get_class()

Explanation

Solution: This function accepts any object as an argument and returns its class name as a string.

[#92] PHP 4 did not support instanceof. Instead, which function did it provide?
Correct Answer

(C) is_a()

Explanation

Solution: As of PHP 5.3 is_a() no longer deprecated.

[#93] You use the get_class_methods() function to return the names of all the methods in the class. Which function will you use to print it on the screen?
Correct Answer

(C) print_r

Explanation

Solution: The function get_class_methods returns an array therefore we cannot use echo.

[#94] If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function will you use?
Correct Answer

(C) is_callable()

Explanation

Solution: There is another method which you can use – method_exists() for similar purpose.

[#95] If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?
Correct Answer

(C) Abstract class