Web Data Management - Test #2

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Trunkz0r
T
Trunkz0r
Community Contributor
Quizzes Created: 3 | Total Attempts: 1,459
Questions: 21 | Attempts: 641

SettingsSettingsSettings
Data Management Quizzes & Trivia

Questions and Answers
  • 1. 

    A hidden field

    • A.

      A. appears on the form but its data is hidden

    • B.

      B. has data that is obscured by bullets or asterisks

    • C.

      C. doesn’t appear on the form but its data is sent to the server

    • D.

      D. appears on the form with its data grayed out

    Correct Answer
    C. C. doesn’t appear on the form but its data is sent to the server
    Explanation
    A hidden field is a type of form field that does not appear on the form itself, but its data is still sent to the server when the form is submitted. This is useful for including additional data that the user does not need to see or interact with, but is necessary for processing on the server side.

    Rate this question:

  • 2. 

     Which of the following operators does NOT perform type coercion?

    • A.

      A. ==

    • B.

      B. ===

    • C.

      C. >=

    • D.

      D. !=

    Correct Answer
    B. B. ===
    Explanation
    The operator "===" does not perform type coercion because it strictly compares the values and types of the operands. It returns true if both the value and the type of the two operands are equal, and false otherwise. This means that it does not automatically convert the types of the operands before comparing them, unlike the other operators mentioned.

    Rate this question:

  • 3. 

    Which type of loop will always execute its code at least once?

    • A.

      While

    • B.

      Do-while

    • C.

      For

    • D.

      For-in

    Correct Answer
    D. For-in
    Explanation
    The for-in loop in JavaScript is used to iterate over the properties of an object. It will always execute its code at least once because it iterates over each property in the object, even if there are no properties present. This makes it different from other loops like while, do-while, and for, which may not execute their code if the initial condition is not met.

    Rate this question:

  • 4. 

    Which of the following statements will restart the execution of a loop?

    • A.

      Halt

    • B.

      Continue

    • C.

      Stop

    • D.

      Break

    Correct Answer
    B. Continue
    Explanation
    The statement "continue" is used to restart the execution of a loop. When the "continue" statement is encountered within a loop, it skips the remaining code in the current iteration and moves on to the next iteration. This allows the loop to continue executing without interruption. Unlike the "break" statement, which completely terminates the loop, "continue" allows the loop to continue iterating. Therefore, "continue" is the correct statement to restart the execution of a loop.

    Rate this question:

  • 5. 

    What does $message contain after the following code executes? $rate = 0.1;   if ( ! is_numeric($rate) ) {    $message = 'Rate is not a number.';   } else if ($rate < 0) {    $message = 'Rate cannot be less than zero.';   } else if ($rate > 0.2) {    $message = 'Rate cannot be greater than 20%.';   } else {    $message = 'Rate is valid.';   }

    • A.

      Rate is not a number.

    • B.

      Rate cannot be less than zero.

    • C.

      Rate cannot be greater than 20%.

    • D.

      Rate is valid.

    Correct Answer
    D. Rate is valid.
    Explanation
    The variable $message will contain the string "Rate is valid." This is because the code first checks if $rate is not a number using the is_numeric() function. Since $rate is a number (0.1), the first condition is false. Then it checks if $rate is less than 0, which is false. Next, it checks if $rate is greater than 0.2, which is also false. Therefore, the final condition is true and the value of $message is set to "Rate is valid."

    Rate this question:

  • 6. 

    What does $message contain after the following code executes?   $age = 19;   $score = 750;   if ( $age >= 21 && $score >= 700 ) {    $message = 'Loan approved';   } else if ( $age >= 21 && $score >= 650 ) {    $message = 'Cosigner needed.';   } else if ( $age >= 18 && $score >= 680 ) {    $message = 'Two cosigners needed.';   } else {    $message = 'Loan denied.';   }

    • A.

      Loan approved.

    • B.

      Cosigner needed.

    • C.

      Two cosigners needed.

    • D.

      Load denied.

    Correct Answer
    C. Two cosigners needed.
    Explanation
    The variable $message will contain the value "Two cosigners needed." after the code executes because the conditions in the if-else statements are checked in order. Since the age is not greater than or equal to 21 and the score is not greater than or equal to 700, the first condition is not met. The second condition is also not met because the score is not greater than or equal to 650. However, the third condition is met because the age is greater than or equal to 18 and the score is greater than or equal to 680. Therefore, the code assigns the value "Two cosigners needed." to the variable $message.

    Rate this question:

  • 7. 

    What does $message contain after the following code executes?   $statusCode = "403";   switch ( $statusCode ) {    case "200":    $message = "OK";    break;    case "403":    $message = "Forbidden";    break;    case "404":    $message = "Not Found";    break;    default:    $message = "Unknown Status";    break;   }

    • A.

      OK

    • B.

      Forbidden

    • C.

      Not Found

    • D.

      Unknown Status

    Correct Answer
    B. Forbidden
    Explanation
    After the code executes, the variable $message will contain the string "Forbidden". This is because the value of $statusCode is set to "403" and the switch statement checks each case to see if it matches the value of $statusCode. Since the case "403" matches, the code inside that case is executed, which sets the value of $message to "Forbidden".

    Rate this question:

  • 8. 

    What does $message contain after the following code executes?   $message = "L: ";   for ($i = 0; $i < 10; $i++ ) {    $message .= $i . ", ";    if ($i == 7) break;   }

    • A.

      L: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

    • B.

      L: 0, 1, 2, 3, 4, 5, 6, 7,

    • C.

      L: 1, 3, 5, 7, 9,

    • D.

      L: 1, 3, 5, 7

    Correct Answer
    B. L: 0, 1, 2, 3, 4, 5, 6, 7,
    Explanation
    The variable $message contains the string "L: 0, 1, 2, 3, 4, 5, 6, 7," after the code executes. The loop iterates from 0 to 9, appending the value of $i followed by a comma and a space to the $message variable each time. When $i reaches 7, the loop breaks and the code stops appending values to $message.

    Rate this question:

  • 9. 

    When you use the substr function to extract a substring from a string, you need to at least pass an   argument that gives

    • A.

      The characters in the substring that you’re looking for

    • B.

      The starting position of the substring

    • C.

      The length of the substring

    • D.

      The separators for the substring

    Correct Answer
    B. The starting position of the substring
    Explanation
    When using the substr function to extract a substring from a string, the starting position of the substring is necessary. This argument indicates the position in the original string where the desired substring begins. Without specifying the starting position, the function would not know where to begin extracting the substring.

    Rate this question:

  • 10. 

    A “natural” comparison of two values

    • A.

      Is case-sensitive

    • B.

      Is case-insensitive

    • C.

      Puts both “09” and “9” before “10”

    • D.

      Puts “10” before both “09” and “9”

    Correct Answer
    C. Puts both “09” and “9” before “10”
    Explanation
    The correct answer is "puts both '09' and '9' before '10'". In a natural comparison of two values, the comparison is done based on the numerical value of the characters. In this case, both "09" and "9" are considered smaller than "10" because the comparison is not based on the length or the leading zero in the values. Therefore, both "09" and "9" are placed before "10" in the natural comparison.

    Rate this question:

  • 11. 

    What is stored in $message by the code that follows? $message = "The file is in \"C:\\My Documents\"";

    • A.

      The file is in C:\My Documents

    • B.

      B. The file is in "C:\My Documents"

    • C.

      C. The file is in C:\\My Documents\

    • D.

      The file is in "C:\\My Documents\"

    Correct Answer
    B. B. The file is in "C:\My Documents"
    Explanation
    The code assigns the string "The file is in \"C:\My Documents\"" to the variable $message. The backslashes are used to escape the quotation marks and indicate that they are part of the string.

    Rate this question:

  • 12. 

    Suppose that $name contains a last name followed by a comma and a space, followed by a first   name. Then, you can store the first and last names in variables with code like this:

    • A.

      $i = strpos($name, ', '); $first_name = substr($name, 0, $i); $last_name = substr($name, $i+1);

    • B.

      B. $i = strpos($name, ', '); $first_name = substr($name, 0, $i); $last_name = substr($name, $i+2);

    • C.

      C. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+1);

    • D.

      D. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2);

    Correct Answer
    D. D. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2);
    Explanation
    The correct answer is d because the code is trying to extract the last name and first name from the given string. The strpos() function is used to find the position of the comma and space in the string, and the result is stored in the variable $i. Then, the substr() function is used to extract the last name from the start of the string up to the position of the comma, and the result is stored in the variable $last_name. Finally, the substr() function is used again to extract the first name from the position after the comma and space to the end of the string, and the result is stored in the variable $first_name.

    Rate this question:

  • 13. 

    In an if statement, which is a correct right way to find out whether the string in $a comes before   (is less than) the string in $b in a case-insensitive comparison?

    • A.

      A. if ($a < $b)

    • B.

      B. if ((strtolower($a) < (strtolower($b))

    • C.

      C. if (strcomp($a, $b) < 1)

    • D.

      D. if (strnatcomp($a, $b) < 1)

    Correct Answer
    B. B. if ((strtolower($a) < (strtolower($b))
    Explanation
    The correct way to find out whether the string in $a comes before the string in $b in a case-insensitive comparison is by using option b. The function strtolower() is used to convert both strings to lowercase before comparing them using the less than operator (

    Rate this question:

  • 14. 

    Suppose that $name contains a last name followed by a comma and a space, followed by a first   name. Then, you can store the first and last names in variables with code like this:

    • A.

      A. $name = implode(', ', $name); $last_name = $name[0]; $first_name = $name[1];

    • B.

      B. $name = implode(', ', $name); $last_name = $name[1]; $first_name = $name[0];

    • C.

      C. $name = explode(', ', $name); $last_name = $name[0]; $first_name = $name[1];

    • D.

      D. $name = explode(', ', $name); $last_name = $name[1]; $first_name = $name[0];

    Correct Answer
    C. C. $name = explode(', ', $name); $last_name = $name[0]; $first_name = $name[1];
    Explanation
    The correct answer is c. $name = explode(', ', $name); $last_name = $name[0]; $first_name = $name[1];

    This is the correct answer because the code is using the explode function to split the string into an array based on the comma and space delimiter. The first element of the array will be the last name and the second element will be the first name. Therefore, $name[0] will store the last name and $name[1] will store the first name.

    Rate this question:

  • 15. 

    If you want to round a number within an arithmetic expression, which function should you use?

    • A.

      Number_format

    • B.

      Sprintf

    • C.

      Round

    • D.

      Option 4

    Correct Answer
    C. Round
    Explanation
    The round function should be used to round a number within an arithmetic expression. This function allows you to round a number to the nearest integer, according to the standard rounding rules. By using the round function, you can ensure that the result of the arithmetic expression is a rounded number, rather than a decimal or fraction.

    Rate this question:

  • 16. 

    If you want to generate a random number that ranges from 1000 to 500,000 as a multiple of 100   (1000, 1100, 1200, etc.), and store it in a variable named $number, you can use the code that   follows.

    • A.

      $number = mt_rand(1000,500000);

    • B.

      $number = mt_rand(100,50000); $number *= 10;

    • C.

      $number = mt_rand(1,500); $number *= 1000;

    • D.

      $number = mt_rand(10,5000); $number *= 100;

    Correct Answer
    D. $number = mt_rand(10,5000); $number *= 100;
    Explanation
    The correct answer is $number = mt_rand(10,5000); $number *= 100;. This is because the mt_rand function generates a random number between the given range, in this case, between 10 and 5000. Then, the $number variable is multiplied by 100, which ensures that the generated number is a multiple of 100.

    Rate this question:

  • 17. 

    When you create a DateInterval object, you pass it one argument that specifies one or more of the following:

    • A.

      Years, months, days

    • B.

      Hours, minutes, seconds

    • C.

      Years, months, days, hours, minutes, seconds

    • D.

      Years, months, weeks, days, hours, minutes, seconds

    Correct Answer
    D. Years, months, weeks, days, hours, minutes, seconds
    Explanation
    The correct answer is years, months, weeks, days, hours, minutes, seconds. When creating a DateInterval object, you can pass it multiple arguments to specify different units of time. This allows you to create intervals that include years, months, weeks, days, hours, minutes, and seconds all at once.

    Rate this question:

  • 18. 

    Which of the following statements is NOT a valid way to create a timestamp named $birthdate that represents December 2, 1969?

    • A.

      $birthdate = mktime(0, 0, 0, 12, 2, 1969);

    • B.

      $birthdate = mktime(12, 2, 1969);

    • C.

      $birthdate = strtotime('1969-12-02');

    • D.

      $birthdate = strtotime('12/02/1969');

    Correct Answer
    B. $birthdate = mktime(12, 2, 1969);
    Explanation
    The mktime() function requires at least 6 parameters: hour, minute, second, month, day, and year. In the given statement, only three parameters are provided, which is not a valid way to create a timestamp.

    Rate this question:

  • 19. 

    To create a DateTime object that represents a due date that’s 90 days after the current date, you use the following code:

    • A.

      $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date->add($days);

    • B.

      b. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days); (Technically, the book says that: $due_date->add($checkout_length); is the proper way to use the ->add() method without the $due_date = to the left.

    • C.

      $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date + $days;

    • D.

      $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date + $days;

    Correct Answer
    B. b. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days); (Technically, the book says that: $due_date->add($checkout_length); is the proper way to use the ->add() method without the $due_date = to the left.
    Explanation
    The correct answer is b. The code correctly creates a DateTime object that represents a due date that is 90 days after the current date. It first creates a DateInterval object with a period of 90 days. Then, it creates a DateTime object representing the current date. Finally, it uses the add() method to add the DateInterval to the DateTime object, resulting in a new DateTime object representing the due date.

    Rate this question:

  • 20. 

    Code example 10-1 $current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) {    $overdue_message = $due_days_diff->format(        '%y years, %m months, and %d days overdue.'); } 14. (Refer to code example 10-1) If $due_date contains a DateTime object, $due_date_diff will contain

    • A.

      A TimeStamp object

    • B.

      A DateTime object

    • C.

      A DateInterval object

    • D.

      A TimeInterval object

    Correct Answer
    C. A DateInterval object
    Explanation
    The variable $due_days_diff is assigned the result of the diff() method, which calculates the difference between the current date and the due date. The diff() method returns a DateInterval object, which represents the difference between two dates or times. Therefore, if $due_date contains a DateTime object, $due_days_diff will also be a DateInterval object.

    Rate this question:

  • 21. 

    Code example 10-1 $current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) {    $overdue_message = $due_days_diff->format(        '%y years, %m months, and %d days overdue.'); } (Refer to code example 10-1) If $due_date contains a DateTime object for a date that comes 1 month and 7 days before the date stored in the $current_date variable, what will $overdue_message contain when this code finishes executing:

    • A.

      0 years, 1 months, and 7 days overdue.

    • B.

      -0 years, -1 months, and -7 days overdue.

    • C.

      1 month and 7 days overdue.

    • D.

      Overdue_message won’t be set because the if clause won’t be executed

    Correct Answer
    A. 0 years, 1 months, and 7 days overdue.
    Explanation
    The code calculates the difference between the current date and the due date using the diff() method of the DateTime object. If the current date is greater than the due date, the if clause is executed and the $overdue_message is set to the formatted string of the difference in years, months, and days. In this case, the difference is 0 years, 1 month, and 7 days, so the $overdue_message will contain "0 years, 1 months, and 7 days overdue."

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 31, 2014
    Quiz Created by
    Trunkz0r
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.