Exercises
-
To make a variable shared across all objects of a given class, which keyword do you use?
-
Objects are always passed by reference: true or false?
-
Given that dog is a class, poodle is a class inheriting from dog, and $poppy is an object of class poodle, would $poppy be considered an instance of the class dog when using the instanceof keyword?
-
To list all classes currently available to your script, which function should be used:
-
a) list_classes()
-
b) get_classes()
-
c) list_declared_classes()
-
d) get_declared_classes()
-
-
Instanceof and is_subclass_of() are identical: true or false?
-
Which of the following statements are true about interfaces:
-
a) They allow you to force classes to implement a set of functions
-
b) They can be based on other interfaces
-
c) They can be based on other classes
-
d) They are faster than using class inheritance
-
e) All of the above
-
-
When must the "override" keyword be used:
-
a) Whenever a child class overrides a function inherited from its parent
-
b) Whenever a child class inherits from an interface
-
c) Whenever a child class implements an interface and inherits from a parent class
-
d) Always
-
e) Never
-
-
Objects of an abstract class can only be created when the class is declared final: true or false?



Copyright 2012 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK