Student Center
|
Instructor Center
|
Information Center
|
Home
Sample Code
Choose a Chapter
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Multiple Choice Quiz
True or False
E-Lectures
Feedback
Help Center
Programming the Web Using XHTML and JavaScript
Larry Randles Lagerstrom
Loops and Arrays
Multiple Choice Quiz
1
What does the following improperly indented while loop display? (hint: rewrite it with proper indentation)
var k = 0
while (k < 5)
alert(k)
k++
A)
0, 1, 2, 3, 4
B)
1, 2, 3, 4, 5
C)
0, 1, 2, 3, 4, 5
D)
0, 0, 0, 0, 0, 0, 0, … forever
2
Which is NOT a loop in JavaScript?
A)
do-while
B)
for
C)
while
D)
while-do
3
Which is NOT a loop in JavaScript?
A)
do-3
B)
threepeat
C)
repeat
D)
none of the above are JavaScript loops
4
Which statement creates an array that can hold 7 elements?
A)
var a = new Array[7]
B)
var a = new Array(6)
C)
var a = new array(6)
D)
var a = new Array(7)
5
Suppose a web page includes one form named f with three text fields. Which statement will display what the user has entered in the first one?
A)
alert(document.f.elements[1].value)
B)
alert(document.f.elements[0])
C)
alert(document.f.textbox[0].value)
D)
alert(document.forms[1].elements[1].value)
6
Suppose a web page includes two forms named f1 and f2 with three text fields. Which statement will display what the user has entered in the second text field in the first form?
A)
alert(document.f1.elements[1].value)
B)
alert(document.forms[0].elements[1].value)
C)
alert(document.forms[1].elements[2].value)
D)
both A and B
7
What will be displayed by the following?
var k = 1, answer = "0"
while (k <= 3){
answer = answer + " " + k
k++
}
alert(answer)
A)
0 1 2 3 4
B)
0 1 2 3
C)
10
D)
6
8
What will be displayed by the following?
var k = 1, answer = 0
while (k <= 3){
answer = answer + k
k++
}
alert(answer)
A)
0 1 2 3 4
B)
0 1 2 3
C)
10
D)
6
2003 McGraw-Hill Higher Education
Any use is subject to the
Terms of Use
and
Privacy Policy
.
McGraw-Hill Higher Education
is one of the many fine businesses of
The McGraw-Hill Companies
.