Quiz 4 Flashcards

1
Q

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),

A

C) ​new Date(year, month, day, hrs, mins, secs);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

T/F: ​JavaScript demands strict application of rules for syntax and program structure.

A

F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

D) AT_TARGET

Explanation:

  1. NONE
  2. CAPTURING_PHASE - The event flow is in capturing phase
  3. AT_TARGET - The event flow is in target phase, i.e. it is being evaluated at the event target
  4. BUBBLING_PHASE - The event flow is in bubbling phase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

T/F: The event object contains properties and methods associated with an event.

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A) keydown,keypress,keyup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

​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

A) ​parseFloat(string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

​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

A) function descending(a, b) {
return b - a;

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

​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

A) ​Document objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

​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

A

D) ​do/while

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

​Identify thesyntax of thestatementlabel.

A) ​statement!(label)
B) statements.label
C) ​label = {statements}
D) ​label: statements

A

D) ​label: statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

D) evt.view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

​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”);
A

B) ​var dateDiv = document.getElementById(“dateNow”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A) It allows a function to override another when multiple functions are added.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

T/F: ​A command block is indicated by its opening and closing square brackets [ ].

A

F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
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;
A

C) object.style.cursor = cursorTypes;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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.

A

B) creating interactive web forms and animated graphics.

17
Q

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

A) object .style.property = “value”;

18
Q

T/F: All JavaScript properties must begin with an uppercase letter.

A

F

19
Q

T/F: The keypress event is fired in response to the computer generating a character.

A

T

20
Q

T/F: Good coding practice dictates that global variables must be used as much as possible in a program.

A

F

21
Q

T/F: The event model describes how events and objects interact within a web page and a web browser.

A

T

22
Q

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

A

D) capture

23
Q

​Identify a shortcut key on the keyboard to open the debugging tools.

A) F10
B) F9
C) F8
D) F12

A

D) F12

24
Q

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()

A

B) evt.cancelable

25
Q

T/F: The evt.eventPhase returns the object that is currently experiencing the event.

A

F