Example midterm questions

This is not a practice midterm, but rather just a collection of assorted questions based on midterms from previous years, illustrative of the types of questions that will be asked. Since they are from previous years, and the course has been updated this year, they don't cover all of the material the midterm will; likewise, I dropped a number of previous questions on material we didn't cover. Some of these are relatively short answer, and some require a bit more, so their point values would vary.

  1. What does the browser do with tags it does not understand?
  2. Among the components of a URL, what is the role of the path?
  3. What computing device is Charles Babbage best known for designing?
  4. What is the correct CSS rule to set the background color of table headings of class "special" to bright green?
  5. Give an example of an HTML tag which indicates a physical formatting property.
  6. How did Pascal's machine store information? Jacquard's machine?
  7. Construct a valid URL from the following parts:
    • Protocol: http
    • Domain: www.nytimes.com
    • Path: /stories/2005/07/05
    • File: 17Fount.html
  8. Provide a fragment of HTML code that includes a level-3 header with the word "cookies" and an internal link that allows one to navigate to that header from another appearance of the word "cookies".
  9. Write the Javascript statement that will add 1 to the value of a variable named examGrade
  10. There are (at least) four errors in the following HTML code. Circle each one and give a brief summary of what the problem is.
    <html>
    <head><title>A Document Full of Errors</title></head>
    <body>
    <h1>This is the CS 4 Bloopers Page</h2>
            
    </p>I bet you probably think this web page is a candidate for
    the <storng>Web Pages that Suck</strong> site!<p>       
    <html>
  11. Provide CSS rules and edit the following HTML fragment to illustrate the use of a class selector to change some property (your choice) of the first two elements but not the third.
    <p>My property is changed.</p>
    <ul>
      <li>And so is mine.</li>
      <li>But mine isn't.</li>
    </ul>
  12. This HTML form needs the Javascript function doAddition. Please write the function. It should load the data from the elements alpha and beta, add them together and store the results in element gamma.
    <form>
    <ul>
      <li>Alpha <input type="text" id="alpha" /></li>
      <li>Beta <input type="text" id="beta" /></li>
    </ul>
    Alpha+Beta <span id="gamma"></span>
    <input type="button" onclick="doAddition()" />
    </form>
  13. In Javascript, what is the difference between a single equals sign and a double equals sign? Why do we use two different symbols?
  14. Render the following HTML fragment (i.e., show how it would be displayed by Firefox). Show the layout of the text, and use words to describe the text properties (colors, fonts). For full credit, you must interpret the text properties and not just repeat the style command.
    <table style="font-family: sans-serif;">
      <tr>
        <td>Day</td>
        <td>Topic</td>
        <td>Reading</td>
      </tr>
      <tr>
        <td>Today</td>
        <td colspan="2">
          <span style="color: #0000ff; background-color: #ffffff;">
            Midterm
          </span>
        </td>
      </tr>
    </table>
  15. Use list tags to generate the following [don't worry about the styling you see here, due to the CS 4 stylesheet].
    1. Alpha
      • one
      • two
    2. Beta
      • do
      • re
      • me
  16. Consider the following HTML form:
    <form>
      <p>Enter the number you got correct for each section:</p>
      <ol>
        <li><input type="text" id="q1" size="16" /></li>
        <li><input type="text" id="q2" size="16" /></li>
        <li><input type="text" id="q3" size="16" /></li>
      </ol>  
      <input type="button" value="Click for Your Score" onClick="computeScore()" />
    </form>
    

    When this button is pressed, a Javascript function called computeScore() is called. Your task is to write this function, which should behave as follows:

    1. It reads the numbers of questions answered correctly in each of the three exam sections from the three input text fields, and converts them to numbers using the built-in Javascript function parseInt().
    2. It computes the final score according to the formula
      s = 3*q1 + 5*q2 + 10*q3
      where q1, q2, and q3 are the scores entered for questions 1, 2, and 3, respectively.
    3. It displays the message "Your final score is s", using the built-in Javascript alert() function (replace s with the actual value of the final score you computed).
  17. Consider the following HTML form.
    <form name="order">
      <p>Price: <input type="text" id="price" /></p>
      <p>Tax rate: <input type="text" id="rate" /></p>
      <p>Overnight delivery: <input type="checkbox" id="overnight" /></p>
      <p id="message"></p>
    </form>

    This document displays an order form in which someone can enter the price (e.g., 5.99) and tax rate (e.g., 0.05), and check whether or not they want next-day delivery. Extend it with a button and Javascript code for computing and displaying the total.

    1. The button should invoke your script when clicked.
    2. The script should get the values from the price and rate text boxes, and convert them to floating point numbers (parseFloat).
    3. The total is the price plus the tax (the rate times the price) plus the shipping. The basic shipping charge is 5.00; overnight shipping costs 10.00.
    4. The script should display in the message area the string "Your total is d. Thank you for your order." (where d is replaced with the computed total).