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

Performing Calculations

Multiple Choice Quiz



1

What is displayed by the alert?
var x = 0
x = x + 1
x++
--x
alert(x)
A)0
B)1
C)2
D)3
2

What is displayed by the alert?
var x = 2, y = 3
x += y
x++
x /= y
alert(x)
A)0
B)1
C)2
D)none of the above
3

What is displayed by the alert?
var x = 9, y = 2, z = 4
alert(x + y * z)
A)44
B)17
C)924
D)none of the above
4

What is displayed by the alert?
var x = "9", y = "2", z = "4"
alert(x + y * z)
A)44
B)17
C)924
D)none of the above
5

Given this function declaration:
function g(){
x = 0
//. . .
}
Which statement is true?
A)x is a local variable
B)x is a global variable
C)both A and B
D)neither A nor B
6

Given this function declaration:
function g(){
var x = 0
//. . .
}
Which statement is true?
A)x is a local variable
B)x is a global variable
C)both A and B
D)neither A nor B
7

What does the alert display?
var x = 3
function g(){
var x = 2
alert(x)
}
A)3
B)2
C)x
D)none of the above
8

What does the alert display?
var x = 3
function g(){
var x = 2
}
alert(x)
A)3
B)2
C)x
D)none of the above
9

Assume x has not been declared anywhere in the document. What does the alert display?
function g(){
var y = x + 2
alert(y)
}
A)3
B)2
C)y
D)none of the above
10

What is displayed by the alert when this script is executed?
<script>
function boxofun(x){
return x * x
alert(x * x + " returned")
}
boxofun(5)
</script>
A)25 returned
B)x*x returned
C)5 * 5 returned
D)none of the above




McGraw-Hill/Irwin