1. To make a variable shared across all objects of a given class, which keyword do you use?

  2. Objects are always passed by reference: true or false?

  3. 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?

  4. 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()

  5. Instanceof and is_subclass_of() are identical: true or false?

  6. 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

  7. 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

  8. Objects of an abstract class can only be created when the class is declared final: true or false?


Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Further reading >>

Previous chapter: Summary

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.