Quiz: Web Programming Practice Test

40 Questions | Total Attempts: 491

SettingsSettingsSettings
Please wait...
Quiz: Web Programming Practice Test

.


Questions and Answers
  • 1. 
    If the prompt method displays a dialog box, and the user enters some text and clicks on the OK button, what does the prompt method return?
    • A. 

      A null value

    • B. 

      A Boolean value

    • C. 

      A Boolean value

    • D. 

      A string value

  • 2. 
    For the following code, if the user clicks the Cancel button in the first dialog box that’s displayed, a second dialog box is displayed that says... var firstName = prompt("Please enter your first name:"); if ( firstName  == null ) {     alert("You must enter your first name."); } else if (firstName == "") {     alert("First name is required."); } else {     alert("Thank you."); }
    • A. 

      Please enter your first name:

    • B. 

      You must enter your first name.

    • C. 

      First name is required.

    • D. 

      Thank you.

  • 3. 
    What property of the Radio object is used to determine if a radio button is selected?
    • A. 

      The value property

    • B. 

      The checked property

    • C. 

      The selected property

    • D. 

      The radio property

  • 4. 
    For a Textarea object, what property do you use to get the text that has been entered into the text area?
    • A. 

      The value property

    • B. 

      The text property

    • C. 

      The name property.

    • D. 

      The string property.

  • 5. 
    To remove the focus from a control, what method do you use?
    • A. 

      The focus method

    • B. 

      The blur method

    • C. 

      The remove method

    • D. 

      The value method

  • 6. 
    What event occurs when the user selects a new item from a select list?
    • A. 

      The click event

    • B. 

      The dblclick event

    • C. 

      The change event

    • D. 

      The select event

  • 7. 
    For the following code, an event handler named investment_change is var investment_change = function () {     var years = parseInt( $("years").value );     alert("Years: " + years); }   window.onload = function () {     $("investment").onchange = investment_change; }
    • A. 

      Attached to the onload event of the global window object.

    • B. 

      Attached to the onload event of a control with an id of “investment”.

    • C. 

      Attached to the onchange event of the global window object.

    • D. 

      Attached to the onchange event of a control with an id of “investment”.

  • 8. 
    To display data in a span element, you can use the firstChild property to get a pointer to the Text node. Then, what property of the Text node can you use to set the value that’s displayed in the span element?
    • A. 

      The message property

    • B. 

      The text property

    • C. 

      The value property

    • D. 

      The nodeValue property

  • 9. 
    Assuming you have a radio button with an id of “contact_via”, which of the following statements selects that radio button?
    • A. 

      $("contact_via").selected = true;

    • B. 

      $("contact_via").checked = true;

    • C. 

      $("contact_via").value = true;

    • D. 

      $("contact_via").value = true;

  • 10. 
    How can you clear a check from a Checkbox object?
    • A. 

      Set its clear property to true

    • B. 

      Set its checked property to false

    • C. 

      Set its value property to an empty string

    • D. 

      Set its value property to an empty string

  • 11. 
    The _______ property of the Number object returns the largest positive value that JavaScript can represent.
  • 12. 
    In JavaScript, _________ represents a value that isn’t a valid number.
  • 13. 
    The ____________ method of the Math object can be used to generate and return a decimal number that’s greater than or equal to 0 but less than 1.
  • 14. 
    The _________ property of a string returns the number of characters in the string.
  • 15. 
    The _____________ method of a Date object returns the month in local time with a value of 0 for January, 1 for February, and so on.
  • 16. 
    If a numerical operation returns a number greater than the largest possible JavaScript value, it returns
    • A. 

      NaN

    • B. 

      -NaN

    • C. 

      Infinity

    • D. 

      -Infinity

  • 17. 
    What method of the Number object returns a string with the number rounded to the specified number of decimal places?
    • A. 

      The toString method

    • B. 

      The round method

    • C. 

      The toPrecision method

    • D. 

      The toFixed method

  • 18. 
    If the count variable has a value of 1, what is the value of the test variable after the following statement is executed? var test = (count == 1) ? "errors" : "error";
    • A. 

      Count

    • B. 

      1

    • C. 

      Errors

    • D. 

      Error

  • 19. 
    What method of the Math object can be used to return the largest value from the values that are passed to it?
    • A. 

      The Math.max method

    • B. 

      The Math.ceil method

    • C. 

      The Math.pow method

    • D. 

      The Math.abs method

  • 20. 
    What text does the following code display in a dialog box? alert("The file is in \"C:\\My Documents\"");
    • A. 

      The file is in C:\My Documents

    • B. 

      The file is in "C:\My Documents"

    • C. 

      The file is in C:\\My Documents\

    • D. 

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

  • 21. 
    The equality operators convert data from one type to another before performing a comparison, but the ______________ operators do not convert data before performing a comparison.
  • 22. 
    The ___________ operator returns a true value if the expression on its left is greater than or equal to the expression on its right.
  • 23. 
    The ___________ operator returns a true value when the expression on both sides of the operator are true.
  • 24. 
    The ________________ operator has the highest precedence of the logical operators.
  • 25. 
    The ________________ loop tests its conditional expression at the end of the loop.
Back to Top Back to top