|
|
Short answers must be brief. All answers are worth 1-2 points, unless noted.
1. Write
JavaScript statement(s) to declare three variables (you pick the names) and
initialize the last one to 0.
2. [4]
Using JavaScript, write a world famous iteration that loops five times.
3. [3] Using JavaScript, write statement(s)
that tests the variable upDown, and if its value is less than or equal to 0, assign the
variable letter the first letter of the alphabet,
and if its value is greater than 0, assign the variable letter the last letter of the alphabet.
4. [3] Using HTML/JavaScript, define a button
labeled “Reset” with the property that when the button is “pushed”, the
variable status is assigned 0.
5. What is
the purpose of the program counter (PC) in a computer?
6. Matching
For each
word or phrase in column A, give the letter of the word, phrase or programming
structure of column B that most closely matches or illustrates its meaning.
A B
____ Event handler A.
onChange
____ JavaScript variable B.
document.images[0].src=Pix[i].src
____ Syntax rule C.
<form> </form>
____ JavaScript string literal D. 'timerID'
____ y++ E.
timerID
____ Statement to update an image F. y = (y+1)
____ Equality test, outcome unknown G. y==(y + 1)
____ Equality test, outcome obvious H. var A = new Array;
____ An array declaration I. Closed curly brace is never followed by
‘;’
____ Form tags J.
timerID==timerid
7. Circle the letters of the legal assignment
statements in JavaScript.
(a) 2 = num + 1; (b) zero = “zero”; (c)
“zero” = zero; (d) zero = 0;
(e) zero + num = 1;
8. In the digital representation of the Oxford
English Dictionary, metadata was included with the dictionary’s content so that
______________________________________________________
____________________________________________________________________________
9. Give the
five properties of algorithms.
a)
______________________________________________
b)
______________________________________________
c)
______________________________________________
d)
______________________________________________
e)
______________________________________________
10. List
the five steps of the fetch/execute cycle
_________________________________________
_________________________________________
_________________________________________
_________________________________________
_________________________________________
11. Give three ways that water glasses can be used for the
PandA representation.
a) _________________________________________________________
b) _________________________________________________________
c) _________________________________________________________
12. For
each lettered program component, enter its letter with the correct term in the
box.
___ Parameter ___ Function Declaration ___ Predicate ___ Argument ___ Function Call ___ Indirect Reference ___ Continuation Test
___ Index Expression
<html><head><title>Spinner5</title></head>
<body bgcolor="white">
<img src="new0.gif">
<img src="new0.gif">
<script language='JavaScript'>
var i, pref = new Array(4);
var frame=1, timerID;
for (i=1; i<5; i++){
A
pref[i-1] = new Image;
pref[i-1].src="new"
+ (i-1) + ".gif";
} B
timerID=setTimeout("animate(1)",5000);
C
function animate(frame){
D
document.images[0].src=pref[frame].src
if (frame == 0)
F E
timerID =
setTimeout("animate(1)",5000);
else G
timeriD = setTimeout("animate("
+((frame+1)%4)+")",30);
}
</script></body></html>
13. Integrated Circuits (ICs) have made the
Information Age possible. State the two most important properties of intrated
circuits, and briefly state what they are:
a)
______________________________________________________________________
b)
______________________________________________________________________
14. When a computer performs a machine
instruction such as ADD 3000, 3600, 5000, …
a)
What
do the three numbers refer to? _________________________________________
b)
Why is
this (answer to (a)) better than
referring to specific values?
15. [6] Show the output from the following HTML/JavaScript program. The GIFs mentioned are all of the same size and show images of whales. (Show the differences among the whales by which way they are swimming: left, right, up or down.)
<html><head><title>Sample</title></head>
<body>
<img src='orca.gif'>
<script language='JavaScript'>
var i;
document.write('<img src="humpback.gif"> ');
document.write('<img src="minke.gif"> ');
document.write('<br>');
for (i=2; i<=10; i=i+2){
document.write('<> ');
}
document.images[2].src="orca.gif";
</script>
</body>
</html>
16. [10] The random number generation function in JavaScript
is Math.random() and the function to “round down” is Math.floor(). In English, the computation to
select a random number between 0 and r, where r is an integer for the upper limit of the range, is:
round down the result of multiplying the range times the random number. [The is the operation from the “Pick a
Random Number” computation on the Memory Bank program.] Write a JavaScript function for the
computation.