Name: 
 

Tutorial 10



True/False
Indicate whether the statement is true or false.
 

 1. 

In Java, programs run on the client side.
 

 2. 

In Java, programs cannot write content to the hard disk.
 

 3. 

Early on, a problem with Java was that nonprogrammers found it difficult to learn and use.
 

 4. 

Essentially, Java and JavaScript are the same.
 

 5. 

Users need to work with a developer’s kit to compile a JavaScript program.
 

 6. 

JavaScript commands can be inserted directly into an HTML file rather than being placed in a separate program file.
 

 7. 

Placing a JavaScript program in an external file allows you to hide the program code from the user.
 

 8. 

Internet Explorer interprets JavaScript as being identical to JScript.
 

 9. 

The document.write() and document.writeln() methods reflect the object-oriented nature of the JavaScript language.
 

 10. 

Most JavaScript commands and names are not case-sensitive.
 

 11. 

You cannot use words that JavaScript has reserved for other purposes when you create a variable name.
 

 12. 

Conditional operators allow you to create expressions that are both efficient and compact.
 

 13. 

There is no limit to the number of function parameters that a function may contain.
 

 14. 

Function parameters must be placed within parentheses, following the function name, and the parameters must be separated by periods.
 

 15. 

Where you place a function in the HTML file is unimportant.
 

 16. 

The function definition in an HTML file must be placed immediately after the command that calls the function.
 

 17. 

When the browser loads the HTML file containing a function, the browser bypasses the function without executing it; the function is executed only when called by another JavaScript command.
 

 18. 

If you try to call a function before it is defined, you might receive an error message from the browser.
 

 19. 

It is common practice for JavaScript programmers to create libraries of functions located in external files to be easily accessible to many Web pages.
 

 20. 

The && operator returns a value of true if any of the Boolean expressions it connects are true.
 

 21. 

The If statement runs a set of commands if the condition is true, but it does nothing if the condition is false.
 

 22. 

Each element in an array is identified by its index, which is an integer displayed between parentheses.
 

 23. 

If you do not specify an array size, JavaScript increases the size of the array as you add more elements.
 

 24. 

A program loop is a set of instructions that is executed repeatedly.
 

 25. 

The For loop allows you to create a group of commands to be executed a set number of times through the use of a matrix that tracks the number of times the command block has been run.
 

 26. 

For loops cannot be nested inside one another.
 

 27. 

The For loop is limited to incrementing the value of its counter by 1.
 

 28. 

Given a For loop counter of “for (i = 5; i > 0; i--)”, the counter values are 1, 2, 3, 4, and 5.
 

 29. 

Given a For loop counter of “for (i = 2; i <= 64; i *= 2)”, the counter values are 2, 4, 8, 16, 32, and 64.
 

Modified True/False
Indicate whether the statement is true or false.  If false, change the identified word or phrase to make the statement true.
 

 30. 

With server-side scripts, computing is distributed over the Web so that no one server is overloaded with programming requests. _________________________

 

 31. 

Although the standard developed by the ECMA is called ECMAScript, browsers still generally refer to it as VBScript. _________________________

 

 32. 

If you place JavaScript code in a separate file, the different pages in your Web site can use the programs you write in the same way that an entire site can use an external style sheet. _________________________

 

 33. 

In the strict DTD for XHTML 1.0, the language attribute is used to indicate the script language in the <script> tag. _________________________

 

 34. 

You can declare a variable in JavaScript by assigning the variable a value. _________________________

 

 35. 

It is considered good programming practice to include the var command whenever you create a variable. _________________________

 

 36. 

Binary operators include the increment, decrement, and negation operators. _________________________

 

 37. 

The /= assignment operator divides the variable on the left by the variable on the right and assigns the remainder to the variable on the left. _________________________

 

 38. 

A group of commands set off by curly braces is called a command cluster. _________________________

 

 39. 

Function names, unlike variable names, are case-sensitive. _________________________

 

 40. 

Although not a requirement, one programming convention is to place all of the function definitions used in the Web page within the head section. _________________________

 

 41. 

JavaScript stores date information in terms of seconds. _________________________

 

 42. 

A comparison operator comparing the value of one element with that of another creates a conditional expression that is either true or false. _________________________

 

 43. 

The single equal sign is an equivalency operator and is not used for making comparisons. _________________________

 

 44. 

The following logical expression is true only if x is less than 100 and y is equal to 20: (x < 100) && (y == 20). _________________________

 

 45. 

A conditional operator tests whether a specific condition is true and returns one value if the condition is true and a different value if the condition is false. _________________________

 

 46. 

An index is an ordered collection of values referenced by a single variable name. _________________________

 

 47. 

Once an array is created, you create values for each individual element in the array. _________________________

 

 48. 

The first element in an array has an index value of 1. _________________________

 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 49. 

____ is a programming language specifically designed for Web pages.
a.
JavaScript
b.
Perl
c.
C++
d.
All of the above
 

 50. 

Java requires that users have access to the ____ in order to create an executable Java applet.
a.
DTD
b.
JDK
c.
ECMA
d.
DDL
 

 51. 

____-side programs do not require users to wait for data to be sent over the Internet to a Web server.
a.
Server
b.
File
c.
Client
d.
Database
 

 52. 

____ is the process by which a program is converted from a text file of code into an executable file called an applet.
a.
Inheritance
b.
ECMA
c.
Scripting
d.
Compiling
 

 53. 

The responsibility for the development of a scripting standard has been transferred to an international body called ____.
a.
ECMA
b.
NASA
c.
NSF
d.
W3C
 

 54. 

What is Internet Explorer’s scripting language called?
a.
IEScript
b.
VBScript
c.
Oak
d.
JavaScript
 

 55. 

You use the ____ tag to distinguish JavaScript code from the text that you want displayed on a Web page.
a.
<code>
b.
<JavaScript>
c.
<script>
d.
<js>
 

 56. 

The ____ attribute of the <script> tag is required only if the program is placed in a separate file.
a.
file
b.
where
c.
source
d.
src
 

 57. 

Client-side scripting languages are distinguished by their ____ types.
a.
MIME
b.
DTD
c.
XML
d.
DDL
 

 58. 

For the type attribute, the default language value is ____.
a.
VBScript
b.
JavaScript
c.
JScript
d.
IEScript
 

 59. 

You can hide the script from older browsers that do not support JavaScript by using ____ tags.
a.
slash
b.
<script>
c.
comment
d.
internal
 

 60. 

JavaScript supports comment tags, using a set of double ____ at the beginning of a line that instructs the browser to ignore the line and not interpret it as a JavaScript command.
a.
backslashes
b.
commas
c.
periods
d.
slashes
 

 61. 

One way to handle the way that XML parsers treat the content of a JavaScript program is to place the JavaScript code within a(n) ____ section.
a.
CDATA
b.
PCDATA
c.
XML
d.
ASP
 

 62. 

The text string specified by the document.write() method can be enclosed within ____.
a.
double quotation marks
b.
single quotation marks
c.
commas
d.
Either A or B
 

 63. 

You can display single quotation marks with the document.write() method by enclosing your text string within ____.
a.
periods
b.
double quotation marks
c.
parentheses
d.
brackets
 

 64. 

Each JavaScript command line ends with a(n) ____ to separate it from the next command line in the program.
a.
comma
b.
ampersand
c.
semicolon
d.
period
 

 65. 

____ are useful because they can store information created in one part of your program and use that information in another.
a.
Conditional operators
b.
Logical operators
c.
Assignment operators
d.
Variables
 

 66. 

In naming a variable, the first character must be either a letter or a(n) ____.
a.
underscore
b.
pound sign
c.
number sign
d.
ampersand
 

 67. 

Variable names cannot contain ____.
a.
numbers
b.
spaces
c.
underscore characters
d.
Any of the above
 

 68. 

A(n) ____ variable is any group of characters, such as “Hello” or “Happy Holidays!”
a.
Boolean
b.
text
c.
string
d.
null
 

 69. 

One can create a ____ variable to determine whether the user is running the Netscape browser or not.
a.
null
b.
string
c.
conditional
d.
Boolean
 

 70. 

A(n) ____ variable has no value at all.
a.
null
b.
empty
c.
cipher
d.
negative
 

 71. 

You can declare a variable in JavaScript using the ____ command.
a.
dec
b.
var
c.
this
d.
val
 

 72. 

Before you can use a variable in your program, you need to ____ it.
a.
compile
b.
concatenate
c.
declare
d.
nullify
 

 73. 

When you specify the month with values rather than a text string, you must subtract ____ from the month number, because JavaScript numbers the months 0 for January through 11 for December.
a.
1
b.
2
c.
3
d.
4
 

 74. 

For each part of the date that you want displayed in your Web page, or used in a calculation, you need a date ____ to retrieve its value.
a.
object
b.
function
c.
assignment
d.
method
 

 75. 

The ____ method extracts the year value from the date variable.
a.
extractYear()
b.
getFullYear()
c.
getYear()
d.
thisYear()
 

 76. 

The ____ operator increases a value by 1 unary operator).
a.
+
b.
*
c.
++
d.
~
 

 77. 

____ operators work on two elements in an expression.
a.
Binary
b.
Tertiary
c.
Unary
d.
Increment
 

 78. 

____ operators work on only one variable.
a.
Binary
b.
Unary
c.
Solo
d.
Increment
 

 79. 

The most common assignment operator is the ____.
a.
+=
b.
-=
c.
=
d.
==
 

 80. 

In JavaScript, the expression ____ creates the same result as the expression x = x + y;.
a.
y += x
b.
x = x++
c.
y = x ++ y
d.
x += y
 

 81. 

A function includes the function ____, which identifies it.
a.
name
b.
parameter
c.
term
d.
id
 

 82. 

A function includes its ____, which are values used by the function.
a.
terms
b.
parameters
c.
ids
d.
names
 

 83. 

____ are used to mark the beginning and end of the commands in a function.
a.
Brackets
b.
Parentheses
c.
Curly braces
d.
Commas
 

 84. 

JavaScript stores date information in terms of ____.
a.
days
b.
hours
c.
seconds
d.
milliseconds
 

 85. 

There are many types of conditional statements, one of which is the ____ statement.
a.
If
b.
Else
c.
Then
d.
For
 

 86. 

The ____ comparison operator returns true if variables are equal.
a.
!=
b.
==
c.
>=
d.
<=
 

 87. 

The ____ comparison operator returns true if variables are not equal.
a.
~=
b.
==
c.
!=
d.
++
 

 88. 

The ____ logical operator returns true when both expressions are true.
a.
||
b.
|
c.
==
d.
&&
 

 89. 

The ____ logical operator returns true when either expression is true.
a.
||
b.
|
c.
==
d.
&&
 

 90. 

The ____ logical operator returns true if the expression is false and false if the expression is true.
a.
||
b.
|
c.
&&
d.
==
 

 91. 

The ____ loop allows you to create a group of commands to be executed a set number of times through the use of a counter that tracks the number of times the command block has been run.
a.
While
b.
Do
c.
For
d.
Next
 

 92. 

The command block in a For loop is set off by ____.
a.
parentheses
b.
brackets
c.
periods
d.
curly braces
 

 93. 

Given a For loop counter of “for (i = 1; i <= 5; i++)”, the counter values are ____.
a.
1, 2, 3, 4, and 5
b.
5, 4, 3, 2, and 1
c.
5, 10, 15, 20, and 25
d.
-1, -2, -3, -4, and -5
 

 94. 

Given a For loop counter of “for (i = 0; i <= 360; i += 60)”, the counter values are ____.
a.
60, 120, 180, 240, 300, and 360
b.
0, 60, 120, 180, 240, 300, and 360
c.
0, 60, 120, 180, 240, and 300
d.
0, 120, 240, and 360
 

 95. 

Similar to the For loop, the ____ loop runs a command group as long as a specific condition is met, but it does not employ any counters.
a.
Next
b.
Do
c.
While
d.
If
 
 
nar001-1.jpg
 

 96. 

What is the code missing from the While loop in the figure above, in order to create the table shown?
a.
num--
b.
num*=
c.
num+=2
d.
num++
 

 97. 

In the While loop in the figure above, the num variable starts with a value of ____.
a.
1
b.
2
c.
3
d.
4
 

 98. 

In the While loop in the figure above, the loop ends when the condition that num should be less than or equal to ____ is no longer true.
a.
1
b.
2
c.
3
d.
4
 

Completion
Complete each statement.
 

 99. 

A(n) ____________________ approach to scripting poses problems for the system administrator, who has to be concerned about users potentially overloading the system.
 

 

 100. 

JavaScript is a(n) ____________________ language, in which the program code is converted into an executable application each time it is run.
 

 

 101. 

For Java, compiling is a process by which a program is converted from a text file of code into an executable file called a(n) ____________________.
 

 

 102. 

Internet Explorer supports a slightly different version of JavaScript called ____________________.
 

 

 103. 

A(n) ____________________ is a named element in a program that stores information.
 

 

 104. 

A(n) ____________________ variable can be any number, such as 12, 22.5, or -3.14159.
 

 

 105. 

____________________ variables are variables that accept one of two values, either true or false.
 

 

 106. 

A(n) ____________________ object is an object containing date information.
 

 

 107. 

The keyword ____________________ indicates that you are creating a new object.
 

 

 108. 

The ____________________ method exists for extracting the value of the current month from a date object.
 

 

 109. 

____________________ are JavaScript commands that assign values to your variables.
 

 

 110. 

____________________ are elements that perform actions within the expression.
 

 

 111. 

The + operator belongs to a group of operators called ____________________ operators, which perform simple mathematical calculations.
 

 

 112. 

The ____________________ operator can be used to increase the value of a variable by 1.
 

 

 113. 

Expressions assign values using ____________________ operators.
 

 

 114. 

A(n) ____________________ is a series of commands that performs an action or calculates a value.
 

 

 115. 

To run a function, you insert a JavaScript command containing the function name and any parameters it requires; this process is known as ____________________ a function.
 

 

 116. 

A(n) ____________________ statement is one that runs only when specific conditions are met.
 

 

 117. 

A(n) ____________________ operator compares the value of one element with that of another.
 

 

Matching
 
 
Identify the letter of the choice that best matches the phrase or definition.
a.
applet
e.
arithmetic
b.
variable
f.
increment
c.
expression
g.
assignment
d.
operator
h.
function
 

 118. 

Operator used to increase the value of a variable by 1
 

 119. 

A JavaScript command that assigns a value to your variable
 

 120. 

A series of commands that performs an action or calculates a value
 

 121. 

Type of operator that performs simple mathematical calculations
 

 122. 

Operators that expressions use to assign values
 

 123. 

An executable file created from compiling Java code
 

 124. 

A named element in a program that stores information
 

 125. 

An element that perform actions within an expression
 

Short Answer
 

 126. 

Are there any differences between JScript and JavaScript?
 

 127. 

What is the advantage of placing JavaScript code in a separate file?
 

 128. 

What is the general syntax for the <script> tag, assuming that the script to be referenced exists in an external file?
 

 129. 

Your JavaScript program can be placed anywhere within the HTML file, but where are some places that programmers favor placing their scripts?
 

 130. 

How does the document.writeln() method differ from the document.write() method?
 

 131. 

What happens if you replace the “document.write()” command with the command “Document.Write()”?
 

 132. 

What character must the first character in a variable be? What can the remaining characters be?
 

 133. 

What different types of variables does JavaScript support?
 

 134. 

With respect to string variables, is “Hello’ acceptable? Why or why not?
 

 135. 

Provide an example of a way to create a variable named “Month.”
 

 136. 

Write a command that creates a variable named “Today” that contains information about the current date and time.
 

 137. 

What is the limitation with the getYear() method?
 

 138. 

With what characters must a function name begin?
 

 139. 

What happens if you try to call a function before it is defined?
 

 140. 

What is the general syntax of an If statement?
 

 141. 

What is a dense array?
 

 142. 

An efficient way of populating an array is to specify the array contents in an Array() statement; what is the syntax for this?
 

 143. 

What are the two types of program loops?
 

 144. 

What is the general syntax of the For loop?
 
 
nar002-1.jpg
 

 145. 

Write the For loop missing from the figure above used to write the row of table cells shown in the figure.
 

Essay
 

 146. 

What are the disadvantages of running CGI scripts from the Web server?
 

 147. 

What are the problems of server-side scripts that client-side programs solve? Will client-side programs completely replace CGI scripts?
 

 148. 

List the key differences between Java and JavaScript.
 

 149. 

What is the use of a switch statement? Write its syntax.
 

 150. 

Given a date object

Date(“April 8, 2006, 12:25:28”)

stored in a variable called Today, list six date methods, with the value that corresponds to this date object. (Note: this date is a Saturday)
 



 
Check Your Work     Start Over