Practice Quizzes -- IT 238 The question and answers for each practice quiz will be posted after the quiz closes. The correct answer is marked with *. ------------------------------------------------------ Practice Quiz 1: Closed Jan 18 1. Who designed the first version of HTML? a. Bill Gates b. Grade Hopper c. John von Neumann *d. Tim Berners-Lee 2. Which HTML tab defines an image element that displays the image file female-cardinal.jpg. a. b. c. *d. 3. Which HTML tag does not require a matching end tag? a. *b.
c.
    d. 4. Which HTML tag defines the root element of the page? a. <body> b. <div> *c.<html> d. <span> 5. Which shorthand style for margin is equivalent to the long version of the style? { margin-left: 20px; margin-right: 25px; margin-botton: 30px: margin-top: 35px; } a. p { padding: 20px 25px 30px 35px; } b. p { padding: 30px 20px 25px 35px; } *c. p { padding: 35px 25px 30px 20px; } d. p { padding: 35px 30px 25px 20px; } ------------------------------------------------------ Practice Quiz 2: Closed Jan 25 1. Who invented the JavaScript language? *a. Brendon Eich b. Dennis Richie c. Guido van Rossum d. Larry Ellison 2. How is the parent folder designated in an HTML file? a. ~ b. # c. . *d. .. 3. If the JavaScript object for the button1 with ID="btn1" is defined as var button1 = document.getElementById("btn1"); Which statement attaches the event listener showAnswer to the button? a. button1.addEventListener(click, showAnswer); b. button1.addEventListener("click", showAnswer( )); *c. button1.addEventListener("click", showAnswer); d. button1.addEventListener("click") = showAnswer; 4. What is the output of this JavaScript statement? document.writeln(typedef 4687); a. float b. int *c. number d. string 5. What is the output of this JavaScript statement? document.writeln(2.5e1000); a. 2500 b. 2.5e1000 *c. Infinity d. undefined ------------------------------------------------------ Practice Quiz 3: Closed Feb 1 1. What is the output? for(var n = 1; n <= 20; n += 5) { document.writeln(n + "<br>"); } a. 1 5 10 15 20 *b. 1 6 11 16 c. 10 11 13 16 20 d. 1 20 5 2. How many stars are printed? for(var i = 1; i <= 500; i++) { for(var j = 1; j <= 700; j++) { document.writeln("*<br>"); } } a. 35 b. 120 c. 350 *d. 350,000 3. How many stars are printed? for(var i = 1; i <= 500; i++) { document.writeln("*<br>"); } for(var j = 1; j <= 700; j++) { document.writeln("*<br>"); } a. 35 *b. 1,200 c. 3,500 d. 350,000 4. How many stars are printed? for(var i = 1; i <= 500; i++) { } for(var j = 1; j <= 700; j++) { } document.writeln("*<br>"); a. 0 *b. 1 c. 120 d. 350 5. What is the output? Try it out in a browser if you are not sure. var n; document.writeln(n + 1); a. 0 b. 1 *c. NaN d. undefined ------------------------------------------------------ Practice Quiz 4: Closed Feb 8 1. Which choice is a properly defined object literal? a. var k = [ name: "Alice", gender: "F", age: 11 ]; b. var k = [ name -- "Alice" / gender -- "F" / age -- 11 ]; *c. var k = { name: "Alice", gender: "F", age: 11 }; d. var k = { name -- "Alice" / gender -- "F" / age -- 11 }; 2. If s is a JSON string, which method call converts s into an array of object literals? a. var a = JSON.toArray(s); *b. var a = JSON.parse(s); c. var a = s.arrayify( ); d. var a = s.parseJSON( ); 3. An object literal p contains fields with keys firstName and phone. Which choice adds a new field to p with key age and value 19? *a. p.age = 19; b. p.add("age", 19); c. p.append(age, 19); d. p.store("age", 19); 4. What is the value of t after these statements. var s = "Elephant"; var t = s.toUpperCase( ).charAt(4)); a. h *b. H c. p d. P 5. What is the value of s after this statement? var s = `${"234" === 234} / ${"234" == 234"}`; a. false / false *b. false / true c. true / false d. true / true ------------------------------------------------------ Practice Quiz 5: Closed Feb 22 1. Which HTML attribute do you include to gray out an HTML element? *a. disabled b.gray-out c. grayout d. inactive 2. When writing to a textarea element, what do you use to go to a new line? a. <br> b. <r> *c. \n d. \r 3. How is this function written in arrow notation? function add(s, t) { return s + t; } a. var add = s, t -> (s + t); b. var add = (s, t) -> s + t; c. var add = s, t => (s + t); *d. var add = (s, t) => s + t; 4. A button object is defined like this: var button1 = document.getElementById("btn1"); How do you use JavaScript to double the button caption's font size? a. button1.fontSize("200%"); b. button1.font-size = "200%"; c. button1.style.font-size("200%"); *d. button1.style.fontSize = "200%"; 5. If the image object is defined as var image1 = document.getElementById("img1"); How do you display the image file image/tails.png in image1? a. image1.display = "image/tails.png"; b. image1.display("image/tails.png); *c. image1.src = "image/tails.png"; d. image1.fileName("image/tails.png); ------------------------------------------------------ Practice Quiz 6: Closed Mar 1 1. Which JavaScript statements is equivalent to var a = document.querySelector("#btn"); *a. var a = document.getElementById("btn"); b. var a = document.getElementById("#btn"); c. var a = document.getElementsByTagName("btn")[0]; d. var a = document.getElementsByTagName("#btn")[0]; 2. Which JavaScript statement is equivalent to var a = document.querySelector("li"); a. var a = document.getElementById("li"); b. var a = document.getElementsById("li")[0]; c. var a = document.getElementsByTagName("li"); *d. var a = document.getElementsByTagName("li")[0]; 3. Which JavaScript statement is equivalent to var a = document.querySelectorAll("li"); a. var a = document.getElementById("li"); b. var a = document.getElementsById("li")[0]; *c. var a = document.getElementsByTagName("li"); d. var a = document.getElementsByTagName("li")[0]; 4. Which JavaScript statements is equivalent to var a = document.querySelectorAll(".tt"); *a. var a = document.getElementsByClassName("tt"); b. var a = document.getElementsByClassName("tt")[0]; c. var a = document.getElementsByTagName(".tt"); d. var a = document.getElementsByTagName(".tt")[0]; 5. Which JavaScript statement is equivalent to var a = document.querySelector(".tt"); a. var a = document.getElementsByClassName("tt"); *b. var a = document.getElementsByClassName("tt")[0]; c. var a = document.getElementsByTagName(".tt"); d. var a = document.getElementsByTagName(".tt"); ------------------------------------------------------ Practice Quiz 7: Closed Mar 8 1. Which HTML element defines a textfield with contents Alice and id txt1? a. <input type="text" id="id1">Alice</input> *b. <input type="text" value="Alice" id="id1"> c. <textfield id="id1" innerHTML="Alice"> d. <textfield id="id1">Alice</textfield> 2. Which of these HTML elements defines a textfield that can contain only numbers? a. <input type="number" id="id1">236.5</input> *b. <input type="number" id="id1" value="236.5"> c. <numberfield id="id1">236.5</numberfield> d. <numberfield id="id1" value="236.5"> 3. Which HTML element defines a button? a. <button id="btn1" value="Push Me"> b. <button id="btn1" innerHTML="Push Me"> c. <input type="button" id="btn1">Push Me</input> *d. <input type="button" id="btn1" value="Push Me"> 4. Which HTML element defines a radio button that belongs to button group 1 and has id="id1". *a. <input type="radio" id="id1" name="1"> b. <input type="radiobutton" id="id1" group="1"> c. <radio id="id1" name="1"> d. <radio id="id1" name="1"> 5. Which HTML element defines a file upload element? a. <file id="id1"> b. <fileupload id="id1"> *c. <input type="file" id="id1"> d. <input type="fileupload" id="id1"> ------------------------------------------------------ Practice Quiz 8, Closed Mar 15 1. jQuery is a JavaScript ___________ . a. library b. server-side framework c. standard d. version 2. Which is a shorter version of this jQuery statement? $(document).ready(init); a. $( ); b. $(document, init); *c. $(init); d. $(document, "DOMContentLoaded") = init; 3. What is the vanilla JavaScript translation of this jQuery statement? $("input").val("abc"); a. document.findElementByTagName("input")[0].val("abc"); b. document.findElementByTagName("input").value = "abc" *c. document.querySelector("input").value = "abc"; d. document.querySelector("input").value("abc"); 4. What is the vanilla JavaScript translation of this jQuery statement? $("p").text("abc"); a. document.findElementByTagName("p").innerHTML("abc"); b. document.findElementsByTagName("p").innerHTML = "abc"; c. document.querySelector("p").text= "abc"; *d. document.querySelector("p").innerHTML = "abc"; 5. When using jQuery, what is an alternative to downloading the jQuery script jquery-4.0.0.js? Accessing jQuery from _____________ . a. this URL: https://jquery/jquery-4.4.0.js *b. Google's content delivery network site ajax.googleapis.com c. Microsoft's content delivery site network ms.nbc.com d. Oracle's content delivery site javascript.oracle.com ------------------------------------------------------ Practice Quiz 9, Closed Mar 17 1. Which HTML style does the same thing as these JavaScript statements? var pTags = document.querySelectorAll("p"); for(let p of pTags) { p.style.backgroundColor = "red"; } a. p { backgroundColor : red; } *b. p { background-color : red; } c. #p { backgroundColor : red; } d. #p { background-color : red; } 2. Which is an HTML element for a submit button on a form? a. <button>Submit Form</button> b. <button type="submit">Submit Form</button> c. <input type="button" value="Submit Form"> *d. <input type="submit" value="Submit Form"> 3. What is the HTML tag for a dropdown menu? a. <combobox> b. <dropdownmenu> c. <option> *d. <select> 4. What does the action attribute for a form do? a. It cancels the form submission if there are errors in the submitted data. *b. It specifies the URL of the server that will process the form data. c. It specifies if the HTTP command GET is generated by the browser. d. It specifies if the HTTP command POST is generated by the browser. 5. If ev is the event object of the submit event for a form, which JavaScript statement cancels the form submission? a. ev.cancel( ); b. ev.cancelSubmit( ); *c. ev.preventDefault( ); d. ev.preventSubmit( ); ------------------------------------------------------