This exam is closed book, closed notes, closed computer, closed classmates.
Please put all answers on the test sheets.
Make sure your answer is clearly marked and easily distinguished
from work you do to get to the solution.
You should show your work for partial credit.
When done, please staple together your exams sheets and any paper
you use for work and place it face down on the lecture table.
Please please print your name
clearly below, and sign when you hand in the exam,
signifying your adherence to
the honor code and attesting to the work being yours alone.
Name (print) ---------------------------------------------------------------- Signed ---------------------------------------------------------------------
(A) < script > (H) < center > (B) < ol > (I) < hr > (C) < body > (J) < font > (D) < title > (K) < h1 > (E) < head > (L) < br > (F) < tr > (M) < input > (G) < ul > (N) < table > (O) < p > (P) < hr >In an HTML document, which tag would be used to do each of the following (put the corresponding letter in the blank):
i) ________ create an unnumbered list of items ii) ________ create a top level header for the page iii) ________ change the text style to Arial and the color to red iv) ________ create a button to click to run a JavaScript program v) ________ cause a line break vi) ________ add a new row to a table vii) ________ create a line horizontally across the page viii) ________ insert a block of JavaScript code ix) ________ skip a line and indent for a new paragraph x) ________ put the phrase "Mortgage Calculator" in the top bar of the browser
(A) input (H) integer (B) internet (I) byte (C) array (J) bit (D) output (K) world wide web (E) disk (L) CPU (or ALU) (F) function (M) expression (G) string (N) RAM memoryFor each of the following definitions, select the item above that best matches (put the corresponding letter in the blank):
i) ________ single datum of binary information: 0 or 1 ii) ________ slow non-volatile storage iii) ________ basic collection of 8 binary data values iv) ________ grouping of variable locations in a program that can be systematically used by subscript v) ________ place where all arithmetic operations are performed in the computer vi) ________ fast volatile storage
(A) data structure (F) functions (B) HTML (G) AFS and FTP (C) loops (H) variables and assignment (D) conditionals (I) Javascript (E) alert box (J) expressions and value retrieval answers: _____________________
answer: ________________
answer: ________________
var max = 10; var num = 3; var k = 5; // loop index while (k < max) { num = num + k; k = k + 2; } alert(num); answer: ________________
var max = 4; var num = 2; var k ; // loop index for (k = 2; k <= max; k++) { num = num * k; } alert(num); answer: ________________
var x = 3; var f = 12; if (f > 10 ) { f = f * 2 ; } if (f < 20) { f = f - 2; } else { f = 33 - x ; } if (x < 4 ) { x = x + 2; } else if (x > 0) { x = x * 3; } else if (x == 5) { x = x - 2 ; } else { x = -9 ; } alert("x: " + x + ", f: " + f); answer: ________________
function main() { var some = 5; var thing = 10; thing = stomp(some); alert("some: " + some + ", thing: " + thing); } function stomp (arg) { var loc = 3 ; var num = -5 ; num = arg * loc ; return num; } answer: ________________
var max = 4; var arr = new Array(max); var k; for (k=0; k < max; k++) { arr[k] = k * 5 ; } alert( arr[2] ); answer: ________________
var k = 2; var num = 6; switch (k) { case 0: num = 3; break; case 1: num = num + 3; break; case 2: num = num * 3; break; case 3: num = num - 3; break; case 4: num = num / 2; break; } alert( num ); answer: ________________
i) ________ true || false ii) ________ isNaN("midterm"); iii) ________ isNaN(25); vi) ________ Math.floor(12.98765); v) ________ Math.round(12.98765); vi) ________ Math.sqrt(9); vii) ________ !true viii) ________ true && false ix) ________ Number("-225"); x) ________ 10 % 4 Note: what we are asking is what would be printed if the expression was in an alert statement... for example, for (i) what would get printed for alert(true || false)