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) __G_____ create an unnumbered list of items ii) __E_____ create a top level header for the page iii) __J_____ change the text style to Arial and the color to red iv) __M_____ create a button to click to run a JavaScript program v) __L_____ cause a line break vi) __F_____ add a new row to a table vii) __P_____ create a line horizontally across the page viii) __A_____ insert a block of JavaScript code ix) __O_____ skip a line and indent for a new paragraph x) __D_____ 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) __J_____ single datum of binary information: 0 or 1 ii) __E_____ slow non-volatile storage iii) __I_____ basic collection of 8 binary data values iv) __C_____ grouping of variable locations in a program that can be systematically used by subscript v) __L_____ place where all arithmetic operations are performed in the computer vi) __N_____ 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: __B,E,G,I_______
answer: ___ 10001010 ____
answer: ____ 150 _______
var max = 10; var num = 3; var k = 5; // loop index while (k < max) { num = num + k; k = k + 2; } alert(num); answer: __ 24 _________
var max = 4; var num = 2; var k ; // loop index for (k = 2; k <= max; k++) { num = num * k; } alert(num); answer: ___ 48 ________
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: __ x: 5, f: 30 _______
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: __ some: 5, thing: 15 ______
var max = 4; var arr = new Array(max); var k; for (k=0; k < max; k++) { arr[k] = k * 5 ; } alert( arr[2] ); answer: __ 10 __________
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: __ 18 _________
i) _true___ true || false ii) _true___ isNaN("midterm"); iii) _false__ isNaN(25); vi) _12_____ Math.floor(12.98765); v) _13_____ Math.round(12.98765); vi) _3______ Math.sqrt(9); vii) _false__ !true viii) _false__ true && false ix) _-225___ Number("-225"); x) _2______ 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)