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

Custom Objects: Creating and Searching a Database

Multiple Choice Quiz



1

The presence of the this keyword identifies this function as a(n) _____.
function foo(nm){
this.name = nm
}
A)destructor
B)initializer
C)constructor
D)garbage collector
2

What is displayed by the following?
function foo(nm){
this.name = nm
}
var f1 = new foo("Rocky")
var f2 = new foo("Natasha")
alert(f2.name)
A)Rocky
B)Natasha
C)f2.name
D)none of the above
3

Which statement displays "Natasha"?
function foo(nm){
this.name = nm
}
var f1 = new foo("Rocky")
var f2 = new foo("Natasha")
A)alert(f2.nm)
B)alert(f2.name)
C)alert(this.name)
D)this.alert(name)
4

Which statement displays "Natasha"?
function foo(nm){
this.name = nm
}
var f1 = new foo("Rocky")
var f2 = new foo("Natasha")
A)alert(f2.nm)
B)alert(f2.name)
C)alert(f2.this.name)
D)both A and B
5

A JavaScript database containing employee contact information is usually stored where?
A)The user's cookie file
B)In a <script> element on the current web page
C)In a database on the server
D)none of the above
6

The line of code that creates a database record is typically _____ characters in length
A)10
B)100
C)1000
D)10000
7

Which statement correctly creates an object of type Gastropod named "clam" and assigns it to a variable?
A)var shellfish = Gastropod("clam")
B)var clam = new Shellfish("Gasropod")
C)var shellfish = new Gastropod("clam")
D)none of the above
8

Given this constructor:
scientificDiscovery(n, y, s, c){
this.name = n
this.year = y
this.scientist = s
this.country = c
}
Which statement creates an object as a value of the variable d1?
A)var d1.new.scientificDiscovery("relativity", 1905, "einstein", "swiss")
B)var d1.name="relativity", d1.year = 1905, d1.scientist = "einstein", d1.country = "swiss"
C)var d1 = new scientificDiscovery("relativity", 1905, "einstein", "swiss")
D)both A and C
9

Which statement creates an array named disc of size 100?
A)var disc = array[99]
B)var disc = new Array[100]
C)var disc = new array(100)
D)var disc = new array(99)
10

Suppose an array named disc contains 100 objects defined by this constructor:
scientificDiscovery(n, y, s, c){
this.name = n
this.year = y
this.scientist = s
this.country = c
}
Which of these expressions evaluates to true if the name property of the 7th element of disc is equal to "einstein"?
A)disc[6].year == "einstein"
B)disc[7].year == "einstein"
C)disc.year[6] == "einstein"
D)both A and C




McGraw-Hill/Irwin