McGraw-Hill OnlineMcGraw-Hill Higher EducationLearning Center
Student Center | Instructor Center | Information Center | Home
Sample Code
Multiple Choice Quiz
True or False
E-Lectures
Feedback
Help Center


Programming the Web Using XHTML and JavaScript
Larry Randles Lagerstrom

Increasing the Interactivity

Multiple Choice Quiz



1

What is displayed by the following (tricky) example?
var m = 2, n = 3
if(m = n){
alert("equal")
}
else {
alert("not")
}
A)equal
B)not
C)both A and B
D)neither A nor B
2

What is displayed by this poorly indented example when d = 31?
if(d >= 1)
if(d <= 28)
alert("Feb")
else
alert("not Feb")
A)Feb
B)not Feb
C)first Feb is displayed, then not Feb
D)nothing is displayed
3

What is displayed by this example when d = 31?
if(d >= 1){
if(d <= 28)
alert("Feb")
}
else
alert("not Feb")
A)Feb
B)not Feb
C)first Feb is displayed, then not Feb
D)nothing is displayed
4

What is displayed by this example when d = 3?
if (d == 1)
if (d <= 31)
alert(1)
else
alert(2)
else
alert(3)
A)1
B)2
C)3
D)none of the above
5

What is displayed by this example when found is false?
if (found)
alert(1)
else
alert(2)
A)1
B)2
C)first 1 is displayed and then 2 is displayed
D)nothing is displayed
6

What is displayed by this example when found is false?
if (!found)
alert(1)
else
alert(2)
A)1
B)2
C)first 1 is displayed and then 2 is displayed
D)nothing is displayed
7

What does the following display?
if(true == "true")
alert(true)
else
alert(false)
A)true
B)false
C)both A and B
D)neither A nor B
8

Suppose a web page includes a form named f with a checkbox named cb1 that the user has checked. What does the following display?
if(document.f.cb1.checked == "true")
alert(true)
else
alert(false)
A)true
B)false
C)both A and B
D)neither A nor B
9

Suppose a web page includes a form named f with a pop-up menu named veggieMenu, and the user has selected the third item on the menu. What does the following statement display: alert(document.f.veggieMenu.selectedIndex)
A)document.f.veggieMenu.selectedIndex
B)1
C)2
D)3




McGraw-Hill/Irwin