Quiz 4 Flashcards
(25 cards)
Case-Based Critical Thinking Questions
Case 9-2
Robin maintains a web page for updating the metro timings in the city. He would like the website to display the present day’s schedule. To do this, Robin writes a code that includes an object to retrieve the day of the week and then loads the appropriate data into the page.
Identify an expression that Robin must use to define the current date on the web page.
A) this Day(“day”, “month”, “hrs”, “mins”, “secs”, “year”),
B) new date(“hrs”, “mins”, “secs”, “day”, “month”, “year”);
C) new Date(year, month, day, hrs, mins, secs);
D) this.day(hrs, mins, secs, year, month, day),
C) new Date(year, month, day, hrs, mins, secs);
T/F: JavaScript demands strict application of rules for syntax and program structure.
F
In the evt.eventPhase property, identify the phase of the event propagation the object is currently at when its value is 2.
A) NONE
B) BUBBLING_PHASE
C) CAPTURING_PHASE
D) AT_TARGET
D) AT_TARGET
Explanation:
- NONE
- CAPTURING_PHASE - The event flow is in capturing phase
- AT_TARGET - The event flow is in target phase, i.e. it is being evaluated at the event target
- BUBBLING_PHASE - The event flow is in bubbling phase
T/F: The event object contains properties and methods associated with an event.
T
Identify the sequence of the occurrence of events when a user types a keyboard key.
A) keydown,keypress,keyup
B) keyup,keydown,keypress
C) keyup,keypress,keydown
D) keydown,keyup,keypress
A) keydown,keypress,keyup
Identify a function that extracts the first numeric value from the textstring.
A) parseFloat(string)
B) isFinite(value)
C) parseInt(string)
D) isNaN(value)
A) parseFloat(string)
Identify acompare function that sorts numeric values in descending order.
A) function descending(a, b) {
return b - a;
}
B) function descending(a, b) {
return a - b;
}
C) function descending(b, a) {
return b;
}
D) function descending(b, a) {
return a;
}
A) function descending(a, b) {
return b - a;
}
Which of the following can be referenced only after the browser has finished parsing the page content?
A) Document objects
B) Browser objects
C) Customized objects
D) Built-in objects
A) Document objects
The _____ looptests the condition to continue the loop right after the latest command block is run.
A) for
B) forEach
C) while
D) do/while
D) do/while
Identify thesyntax of thestatementlabel.
A) statement!(label)
B) statements.label
C) label = {statements}
D) label: statements
D) label: statements
The _____ object property references the browser window in which the event has occurred.
A) evt.target
B) evt.eventphase
C) evt.currentTarget
D) evt.view
D) evt.view
Identify a command that uses the dateDiv variable to refer the page element with ID dateNow.
A) var dateNow = document.getElementById(dateDiv), B) var dateDiv = document.getElementById(“dateNow”); C) var dateDiv = document.getElementById(dateNow), D) var dateNow = document.getElementById(“dateDiv”);
B) var dateDiv = document.getElementById(“dateNow”);
Which of the following is a true statement about an event listener?
A) It allows a function to override another when multiple functions are added.
B) It permits only one function to be applied to an event listener at a time.
C) It describes how events and objects
interact within a web page and a web browser.
D) It responds to events during the target phase but does not recognize the propagation of events through the capture and bubbling phases.
A) It allows a function to override another when multiple functions are added.
T/F: A command block is indicated by its opening and closing square brackets [ ].
F
Which of the following is the syntax to define a cursor in JavaScript? A) object.style = cursorTypes; B) object.style.cursorTypes = cursor; C) object.style.cursor = cursorTypes; D) object.cursorTypes = cursor.style;
C) object.style.cursor = cursorTypes;
JavaScript is used as a programming tool for:
A) providing virtual reality, diagnosis, and nonlinear controls.
B) creating interactive web forms and animated graphics.
C) managing databases.
D) designing style sheets for websites.
B) creating interactive web forms and animated graphics.
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” >…
A) object .style.property = “value”; B) object.style = property:value C) object:style:property = “value”; D) object.property = style.value
A) object .style.property = “value”;
T/F: All JavaScript properties must begin with an uppercase letter.
F
T/F: The keypress event is fired in response to the computer generating a character.
T
T/F: Good coding practice dictates that global variables must be used as much as possible in a program.
F
T/F: The event model describes how events and objects interact within a web page and a web browser.
T
In the _____ phase, the event moves down the object hierarchy, starting from the root element and moving inward until it reaches the object that initiated the event.
A) analyse
B) bubbling
C) target
D) capture
D) capture
Identify a shortcut key on the keyboard to open the debugging tools.
A) F10
B) F9
C) F8
D) F12
D) F12
Which of the following event properties or methods returns a Boolean value that indicates whether an event can have its default action terminated?
A) evt.stopPropogation()
B) evt.cancelable
C) evt.defaultPrevented
D) evt .stopImmediatePropagation()
B) evt.cancelable