CSCI 215 EXAM 2 UPDATED ACTUAL QUESTIONS AND
CORRECT ANSWERS
Question:
1. The evt.pageY property returns the vertical coordinate (in pixels) of the mouse pointer relative to the
document. True or False
Answer:
True
Question:
2. The evt.target returns the object in which the event was initiated. True or False
Answer:
True
Question:
3. Good coding practice dictates that global variables must be used as much as possible in a program. True
or False
Answer:
False
Question:
4. Identify the correct syntax to prevent a submit button from submitting a web form when clicked using
the prevent default() method.
Answer:
document.querySelector("input[type='submit']").onclick = runForm; function runForm(e) {
e.preventDefault(); }
Question:
5. Named functions are more concise and easier to manage than anonymous functions. True or False
Answer:
False
Question:
6. Identify the mouse event property that returns an integer indicating the mouse button that was pressed,
where 0 = none, 1 = left, 2 = wheel or middle, and 3 = right.
Answer:
evt.which
Question:
7. During a mouse action, events cannot be fired more than once. True or False
Answer:
False
, Question:
8. _________ are actions initiated by a user or a browser, such as clicking on an object on a form or
closing a webpage.
Answer:
Events
Question:
9. Which of the following syntaxes displays a dialog box, causing the user to enter input text?
alert(text[,defaultInput]) confirm(text[,defaultInput]) prompt(text[,defaultInput]) print(text[,defaultInput])
Answer:
prompt(text[,defaultInput])
Question:
10. Which of the following is the correct syntax for a command in JavaScript to apply inline styles using
the following style attribute?
<element style = "property:value">...
Answer:
object.style.property = "value";
Question:
11. Identify a true statement about a function in JavaScript.
A function can be stored as a variable.
An object is passed through a function using the pass by value method.
A special function exists for multithreading in JavaScript.
An object is passed through a function using pass by reference method.
Answer:
A function can be stored as a variable.
Question:
12. Which of the following JavaScript expressions is equivalent to the given HTML code? <div
id="menu1" class="menu">
Answer:
document.getElement- ById("menu1").class- Name = "menu";
Question:
13. Identify the syntax to add an event listener to an object.
Answer:
object.addEventListener(event, function [, capture = false]);
Question:
14. In the following code, identify the value of children.length property if article is the element node.
<article> <h1>The U.S. Constitution</h1> <h2>Preamble</h2> <p>We the People of the United States, in
Order to form a more perfect Union ... </p> </article>
Answer:
3
CORRECT ANSWERS
Question:
1. The evt.pageY property returns the vertical coordinate (in pixels) of the mouse pointer relative to the
document. True or False
Answer:
True
Question:
2. The evt.target returns the object in which the event was initiated. True or False
Answer:
True
Question:
3. Good coding practice dictates that global variables must be used as much as possible in a program. True
or False
Answer:
False
Question:
4. Identify the correct syntax to prevent a submit button from submitting a web form when clicked using
the prevent default() method.
Answer:
document.querySelector("input[type='submit']").onclick = runForm; function runForm(e) {
e.preventDefault(); }
Question:
5. Named functions are more concise and easier to manage than anonymous functions. True or False
Answer:
False
Question:
6. Identify the mouse event property that returns an integer indicating the mouse button that was pressed,
where 0 = none, 1 = left, 2 = wheel or middle, and 3 = right.
Answer:
evt.which
Question:
7. During a mouse action, events cannot be fired more than once. True or False
Answer:
False
, Question:
8. _________ are actions initiated by a user or a browser, such as clicking on an object on a form or
closing a webpage.
Answer:
Events
Question:
9. Which of the following syntaxes displays a dialog box, causing the user to enter input text?
alert(text[,defaultInput]) confirm(text[,defaultInput]) prompt(text[,defaultInput]) print(text[,defaultInput])
Answer:
prompt(text[,defaultInput])
Question:
10. Which of the following is the correct syntax for a command in JavaScript to apply inline styles using
the following style attribute?
<element style = "property:value">...
Answer:
object.style.property = "value";
Question:
11. Identify a true statement about a function in JavaScript.
A function can be stored as a variable.
An object is passed through a function using the pass by value method.
A special function exists for multithreading in JavaScript.
An object is passed through a function using pass by reference method.
Answer:
A function can be stored as a variable.
Question:
12. Which of the following JavaScript expressions is equivalent to the given HTML code? <div
id="menu1" class="menu">
Answer:
document.getElement- ById("menu1").class- Name = "menu";
Question:
13. Identify the syntax to add an event listener to an object.
Answer:
object.addEventListener(event, function [, capture = false]);
Question:
14. In the following code, identify the value of children.length property if article is the element node.
<article> <h1>The U.S. Constitution</h1> <h2>Preamble</h2> <p>We the People of the United States, in
Order to form a more perfect Union ... </p> </article>
Answer:
3