Last Website D Test Ever

28 Questions | Total Attempts: 180

SettingsSettingsSettings
Please wait...
Website Quizzes & Trivia

Website developers have become some of the most looked out people in the world today. Whether a developer or a user, it is important to know how to gauge a good website. The quiz below tests on several website concepts.


Questions and Answers
  • 1. 
    7. To delete a cookie, you
    • A. 

      A. delete the $_COOKIE variable

    • B. 

      B. use the delete_cookie function

    • C. 

      C. use the remove_cookie function

    • D. 

      D. set the cookie’s value to an empty string and its expiration date to a time in the past

  • 2. 
    8. When you use session tracking, each HTTP request includes
    • A. 

      A. a URL that stores the session ID

    • B. 

      B. a cookie that stores the session ID

    • C. 

      C. a cookie that stores the session data

    • D. 

      D. a cookie that stores the session ID and the session data

  • 3. 
    9. The $_SESSION variable for a session
    • A. 

      A. is a regular array

    • B. 

      B. is an associative array

    • C. 

      C. is an object

    • D. 

      D. is a cookie

  • 4. 
    10. If necessary, you can use PHP functions to do all but one of the following. Which one is it?
    • A. 

      A. get the name of the session cookie

    • B. 

      B. get the session ID

    • C. 

      C. generate a new session ID

    • D. 

      D. get the data for a session ID

  • 5. 
    11. The function that follows returns   function coin_toss() {    if (mt_rand(0, 1) == 0) {    $coin = 'heads';    } else {    $coin = 'tails';    }    return $coin;   }
    • A. 

      A. a random value between 0 and 1

    • B. 

      B. a value of either 0 or 1

    • C. 

      C. a value of either “heads” or “tails”

    • D. 

      D. a reference to the $coin variable

  • 6. 
    All of the arguments that are passed to a function are available in an array that can be accessed   by using the
    • A. 

      A. $_ARGUMENTS variable

    • B. 

      B. $_FUNCTION variable

    • C. 

      C. func_get_args function

    • D. 

      D. func_num_args function

  • 7. 
    13. If you create a function that passes an argument by reference, the function
    • A. 

      A. can change the original variable without using a return statement

    • B. 

      B. can change the variable and pass it back by using a return statement

    • C. 

      C. can’t change the variable

    • D. 

      D. must make a copy of the variable before it changes it

  • 8. 
    14. In PHP, function name duplications are likely to occur because
    • A. 

      A. namespaces create logical function groups

    • B. 

      B. all the functions for an application have to be stored in the same file

    • C. 

      C. all functions have global scope

    • D. 

      D. most programmers use the same naming conventions for functions

  • 9. 
    15. To avoid the duplication of function names, you can
    • A. 

      Use namespaces

    • B. 

      B. Use libraries

    • C. 

      C. Store function files in lower-level directories

    • D. 

      D. Use include paths

  • 10. 
    11. To prevent other classes from directly accessing the properties of a class, you can code them as    private. Then, to make them available to other classes, you can code
    • A. 

      A. private methods to set and get their values

    • B. 

      B. public methods to set and get their values

    • C. 

      C. a constructor to set and get their values

    • D. 

      D. a destructor to set and get their values

  • 11. 
    When you use object-oriented techniques to implement the MVC pattern, the methods of the   model return the data as either arrays or
    • A. 

      A. classes

    • B. 

      B. objects

    • C. 

      C. properties

    • D. 

      D. result sets

  • 12. 
    When a new class extends a superclass, it inherits the properties and methods of the superclass.   Then, it can
    • A. 

      A. override the inherited properties

    • B. 

      B. override the inherited methods

    • C. 

      C. delete any of the inheritied properties

    • D. 

      D. delete any of the inherited methods

  • 13. 
    To code a constructor for a class named Cart that requires two arguments, you start with this code:
    • A. 

      A. public function Cart($arg1, $arg2) {

    • B. 

      B. public function __construct($arg1, $arg2) {

    • C. 

      C. private function Cart($arg1, $arg2) {

    • D. 

      D. private function __construct($arg1, $arg2) {

  • 14. 
    15. To create an object from a class named Cart that requires two arguments, you code
    • A. 

      A. new Cart($arg1, $arg2)

    • B. 

      B. new Cart(arg1, arg2)

    • C. 

      C. Cart_constructor($arg1, $arg2)

    • D. 

      D. Cart_constructor(arg1, arg2)

  • 15. 
         9.   Which function searches for a regular expression in a string and returns 1 if the pattern is found?
    • A. 

      A. match_preg

    • B. 

      B. preg_match

    • C. 

      C. search_preg

    • D. 

      D. preg_search

  • 16. 
    If a match is found in a global search for a regular expression, the function returns
    • A. 

      True

    • B. 

      1

    • C. 

      C. A count of the number of matches

    • D. 

      A count of the number of matches and an array that contains all of the matches

  • 17. 
    If a match is found when the preg_split function is executed, it returns
    • A. 

      If a match is found when the preg_split function is executed, it returns

    • B. 

      B. An array of all of the matches

    • C. 

      C. An array of the substrings that are created by removing the matches

    • D. 

      D. A count of the number of matches and an array of substrings

  • 18. 
       12.   Regular expressions can be used to 
    • A. 

      A. completely validate all types of user entries

    • B. 

      B. only to check whether user entries have the right format

    • C. 

      C. completely validate some types of user entries

    • D. 

      D. are limited to the validation of string data

  • 19. 
       13.   To get the message that’s related to an exception, you use the 
    • A. 

      A. message property of the exception object

    • B. 

      B. getMessage method of the exception object

    • C. 

      C. message property of the exception class

    • D. 

      D. getMessage property of the exception class

  • 20. 
    An exception is thrown when 
    • A. 

      A. a runtime error occurs in a try block

    • B. 

      B. a runtime error is caught by a catch block

    • C. 

      C. PHP encounters invalid data

    • D. 

      D. a runtime error occurs

  • 21. 
                This pattern can be used to validate a five-digit zip code:
    • A. 

      A. /[d5]/

    • B. 

      B. /+\d[5]?/

    • C. 

      C. /^\d{5}$/

    • D. 

      D. /$\d5^/

  • 22. 
    9. Which of the following statements about associative arrays is NOT true?
    • A. 

      A. You can use the count function to return the number of elements in the array.

    • B. 

      B. You can use both integer and string indexes with an associative array.

    • C. 

      C. You can use a foreach loop to access the values of an associative array but not the indexes

    • D. 

      D. You can delete elements from an associative array.

  • 23. 
    10. Gaps can be introduced into an array in all of the ways that follow, except one. Which one is it?
    • A. 

      A. add a new element with an index that’s beyond the next one that’s available

    • B. 

      B. store an empty value in an array

    • C. 

      C. delete or unset an element from an array

    • D. 

      D. store a NULL value in an array

  • 24. 
    11. You can deal with gaps in an array in all but one of the following ways. Which one is it?
    • A. 

      A. Use the array_values function to remove all gaps and re-index the array.

    • B. 

      B. Use a foreach loop to process the array, which skips elements that contain nulls.

    • C. 

      C. Use a for loop that contains extra code that skips elements that contain nulls.

    • D. 

      D. Use the array_fill function to replace all gaps in the array with empty strings.

  • 25. 
    Which of the following functions removes the next element in a LIFO array (also known as a stack)?
    • A. 

      A. array_shift

    • B. 

      B. array_unshift

    • C. 

      C. array_push

    • D. 

      D. array_pop

Back to Top Back to top