Name: ________________________________
Section: ____________

FIT100 Winter Quarter
University of Washington
Midterm #2
February 18, 2005
Closed book, closed notes, closed neighbor; no calculators
2 points per part except as noted

 
.
To "flatten" the image in Photoshop means...
A. reduce the brightness of color highlights
B. average nearby pixels to produce a fuzzy effect
C. combine multiple layers into one
D. smooth out jagged edges of line segments









 
.
One description of ASCII is...
A. a way to represent any type of digital information
B. an agreed coding scheme for characters
C. a standard for (practically) all the world's languages and alphabets
D. the native or "machine language" of most computers









 
.
When attached to a computer, a headset (earphones) is an example of which kind of computer component?
A. memory
B. CPU
C. storage device
D. input peripheral
E. output peripheral









 
.
Which type of speech act is most like an algorithm?
A. a complaint
B. giving directions
C. proposing marriage
D. apologizing
E. recounting the plot of the 1988 John Carpenter movie They Live.









 
.
Among the steps of the Fetch-Execute cycle, the ALU is principly employed during...
A. IE
B. ID
C. DF
D. EX
E. RR









 
.
With reference to CPU operation, the "PC"...
A. tells which instruction is to be executed next
B. counts the number of clock pulses
C. performs comparisons
D. computes percentages
E. performs simple arithmetic calculations (such as add and subtract)









 
.
In this line of Javascript:
var count = 10 - i;

The "10 - i" can be described technically as...
A. a declaration
B. a variable
D C. a constant
E D. an expression
F E. a function









 
.
var message = "Bill 8 " + "2 many waffles";

the best way to describe what the "+" does in the Javascript above is to say that it
A. adds numbers
B. concatenates strings
C. compiles a statement
D. compiles a program
E. initializes the operation









 
.
Which part of the following HTML could be used within Javascript code elsewhere on the page to locate this particular input element?
<p>
Your first name please:
<input id="firstName" type="text" onchange="fixOutput()" />
</p>
A. the text ("Your first name please:")
B. the input tag
C. the id
D. the type
E. the onchange









 
.
Within an HTML document, you wish to have a small table of one row with two columns.  Which of the following (assumed to be inside a <table>, if not shown), would give you the outline for such a table?
A.
    <tr>
      <td><br>
      </td>
    </tr>
    <tr>
      <td><br>
      </td>
    </tr>
B.
    <tr>
<td> <br>
</td>
<td><br>
</td>
</tr>
C.
 <tr>
<td> <br>
</td>
<td><br>
</td>
</tr>
<tr>
<td><br>
</td>
<td><br>
</td>
</tr>
D.
<table ROWS="1", COLS="2"></table>









 
.
The W3C HTML Validator expects a !DOCTYPE declaration at the beginning of a file.  The purpose of this is...
A. to identify the browser
B. to identify the web server
C. to identify the character encoding
D. to identify the version of HTML
E. to request validation









 
.
"Reproducibility" as discussed in FIT100 refers to...
A. a programming technique in which one variable is copied into another
B. a programming technique in which a statement is executed multiple times
C. getting an error to occur
D. copying files for backup purposes









 
.
Assuming that this code executes, what will be written?

<script type="text/javascript">
var numbers = new Array(4);
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 4;
numbers[3] = 8;
var result = numbers[1] + numbers[2];
document.write(result);
</script>
A. 1 + 2
B. 3
C. 6
D. 8
E. undefined









 
.
Assuming that this code executes, what will be written?

<script type="text/javascript">
var numbers = new Array(4);
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 4;
numbers[3] = 8;
var sum = 2 + 2;
var result = numbers[sum];
document.write(result);
</script>
A. 2
B. 4
C. 8
D. 16
E. undefined









 
.
Assuming this script executes, what will be written?

<script language="Javascript">
var x = 1;
for (var i = 0; i < 2; i++) {
x = i + x;
}
document.write(x);</script>
A. 0
B. 1
C. 2
D. 3
E. 4









 
.
Shown below is the algorithm for sorting CDs exactly as shown in lecture (so don't waste too much time reading it!):

define variable named Artist
 use Artist to refer to the name of the group that made a CD
for all slots in the rack starting at one end
call the current slot alpha
for all the remaining slots in the rack
    call the next slot beta
    Exchange?
        If Artist of the CD in the beta slot is earlier in the
        alphabet than the Artist of the CD in the alpha slot,
        interchange the CDs
next beta
next alpha
done

What is true about this algorithm?

A. Artist has the same value throughout
B. there will always be at least one exchange
C. alpha and beta are never the same (slot)
D. alpha and beta always differ by 1










 
.
Referring to the same algorithm as the previous question -- note that the algorithm mentions "starting at one end" without specifying which end.   Suppose the algorithm is implemented to start at the left end.  What is true?
A. the CDs will be sorted, but in reverse order
B. alpha will always be less than or equal to beta
C. alpha will always be greater than or equal to beta
D. the first and last slots may not be sorted correctly









 
. (worth 3 M.C. questions)
A Javascript function is needed to calculate the cost of a coffee drink.  

There is a base price of 1.00 (one dollar), plus .75 per shot.  The function has one parameter, called "shots", that will contain the requested number of shots.  The function should calculate the total cost and then show it in an alert box.   If the number of shots is less than 1, the alert box should show "Please order at least one shot!".

Complete the function in the space provided.









<script type="text/javascript">
function coffeeCost( shots ) {



















}
</script>