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.
- What does the browser do with tags it does not understand?
- Among the components of a URL, what is the role of the path?
- What computing device is Charles Babbage best known for designing?
- What is the correct CSS rule to set the background color of table headings of class "special" to bright green?
- Give an example of an HTML tag which indicates a physical formatting property.
- How did Pascal's machine store information? Jacquard's machine?
- Construct a valid URL from the following parts:
- Protocol: http
- Domain: www.nytimes.com
- Path: /stories/2005/07/05
- File: 17Fount.html
- 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".
- Write the Javascript statement that will add 1 to the value of a
variable named
examGrade - 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> - 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> - This HTML form needs the Javascript function
doAddition. Please write the function. It should load the data from the elementsalphaandbeta, add them together and store the results in elementgamma.<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> - In Javascript, what is the difference between a single equals sign and a double equals sign? Why do we use two different symbols?
- 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> - Use list tags to generate the following [don't worry about the
styling you see here, due to the CS 4 stylesheet].
- Alpha
- one
- two
- Beta
- do
- re
- me
- Alpha
- 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:- 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(). - 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. - 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).
- 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
- 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.
- The button should invoke your script when clicked.
- The script should get the values from the
priceandratetext boxes, and convert them to floating point numbers (parseFloat). - 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.
- The script should display in the
messagearea the string "Your total is d. Thank you for your order." (where d is replaced with the computed total).