Vous êtes sur la page 1sur 31

JAVA SCRIPT

Javascript Practice Quiz 1Javascript Practice Quiz 1


This is a self-grading exam. Answers are entered by clicking the button
corresponding to your selection. The examination is scored by clicking 'Grade
Test' at the bottom of the form. Correct answers and explanations are found
through hyperlinks at the bottom of the page. You may bypass taking the
examination and simply view the answers by clicking the answer hyperlinks.

Question # 1 (Multiple Choice) Variables are declared in Javascript using which


of the following?
A) dim
B) var
C) function
D) variable

Question # 2 (Multiple Choice) If x=3, then the statement y=x++ sets __________.

A) y to 3, increments x to 4
B) y to 4, increments x to 4
C) It is impossible to answer this without more information.
D) Both a and b are correct.

Question # 3 (Multiple Choice) What property reveals the operating system of the
client computer?
A) appName
B) userAgent
C) appVersion
D) OsVersion

Question # 4 (Multiple Choice) When using the "+" operator with two strings, the
effect can best be described as ________.
A) addition
B) comparison
C) combination
D) concatenation

Question # 5 (Multiple Choice) Which of the following assignment operators


assigns the value of the second operand to the first operand?
A) =
B) =>>
C) &&
D) ||

Question # 6 (Multiple Choice) ________ are the specific property that will be
used.
A) Properties
B) Methods
C) Function
D) Values

1
JAVA SCRIPT
Question # 7 (Multiple Choice) ________ are the actions that the object property
can be made to perform, such as calculation or writing of text.
A) Functions
B) Event handlers
C) Methods
D) Operations

Question # 8 (Multiple Choice) If you have a series of five alerts in a row,


which of the following will occur?
A) Only the last will appear.
B) Each will appear in the order they appear in the script, as the user
clicks through them one at a time.
C) If the user clicks cancel instead of OK, all the alerts will be skipped.
D) You cannot do this without crashing Netscape.

Question # 9 (Multiple Answer) If a file has a "runtime error", it is most


likely caused by which of the following?
A) No closing brace
B) Mismatched data types appear when functions called
C) Undeclared variables located on the wrong side of assignment operators
D) Browser doesn't have appropriate plug-in

Question # 10 (Multiple Choice) Which of the following bitwise operators flips


the bits of its operand?
A) ~
B) &
C) ^
D) %

Question # 11 (Multiple Choice) The location of cookies for Netscape is


________.
A) c:\windows\cookies
B) cookies.txt
C) c:\temp\system
D) c:\windows\system
Question # 12 (True/False) Scripts placed in the body of a web document are
processed before scripts placed in the head.
A) True
B) False

Question # 13 (Multiple Choice) Which of the following is possible in


Javascript?
A) Launch an application on the client computer.
B) Set browser preference settings.
C) Read the server directory.
D) Preprocess data on the client before submission to the server.

Question # 14 (Multiple Choice) If you delete cookies.txt from your hard drive,
what will be the consequence?
A) Some websites may not operate correctly.
B) Another cookies.txt file will be created automatically.
C) Netscape will extract information from its backup cookies file.
D) Netscape will need to be re-installed.
2
JAVA SCRIPT

Question # 15 (Multiple Choice) x/y is the same as ________.


A) divides y by x
B) divides x by y
C) swich x and y
D) %xy

Question # 16 (Multiple Choice) Why would anyone choose to use cookies?


A) retrieve email info automatically for marketing
B) to discourage users that have their cookies turned off
C) store preferences of user
D) to check for unlicensed software

Question # 17 (Multiple Choice) What would be the results of


document.write(anyString.substring(4,7)) on "Netscape"?
A) cap
B) sca
C) ets
D) nets, netscape

Question # 18 (Multiple Choice) Which of the following is the highest in the


Javascript object model hierarchy?
A) radio
B) form
C) checkbox
D) This cannot be answered correctly without knowing whether it is the
Microsoft or Netscape model.

Question # 19 (Multiple Choice)


firstName="John"
lastName="Doe"
fullname= firstName+lastName
In the code above, which of the following will be the result?
A) John Doe
B) JohnDoe
C) This cannot be determined.
D) This will return an error message.

Question # 20 (Multiple Answer) Which of the following bitwise operations are


correct?
A) 15^9 yields 8
B) 15&9 yields 9
C) 15|9 yields 15
D) 15&9 yields 15

Question # 21 (Multiple Choice) Which command holds values in a named space of


memory?
A) dim
B) variable
C) null
D) instance

3
JAVA SCRIPT
Question # 22 (Multiple Answer) Alert boxes ________.
A) annoy the user
B) increase interaction with the web page
C) can request info from the user to be stored as a variable
D) can display the current value of a variable, making them excellent for
troubleshooting

Question # 23 (Multiple Choice) Which of the following bitwise operators returns


a one in each bit position if bits of both operands are ones?
A) |
B) &
C) ^
D) >

Question # 24 (Multiple Choice) In the expression ("Hello," + "Mary"), the +


operator is ________.
A) addition
B) combination
C) concatenation
D) It is impossible to know without the complete function.

Question # 25 (Multiple Choice) What version of Javascript was first supported


by Netscape browser?
A) 1
B) 2
C) 3
D) 4

Question # 26 (Multiple Choice) Which of the following is the most commonly used
Javascript version?
A) 1.2
B) 1.3
C) 1.4
D) 1.5

Question # 27 (Multiple Choice) The following dot notation is referring to which


object?
window.document.body.form.radio
A) window
B) radio
C) form
D) document

Question # 28 (Multiple Choice) The following code is used to ________.


setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://your-site.com";
}
A) redirect to another site
B) refresh the page
C) break out of frames
D) None of the above.
4
JAVA SCRIPT

Question # 29 (Multiple Answer) Which of the following is typically used to


troubleshoot Javascript?
A) comments
B) alert()
C) if...then
D) onError

Question # 30 (Multiple Choice) Which of the following is used to insert a


backslash?
A) \\
B) \back
C) \b
D) \##

Question # 31 (Multiple Choice) If you use an external Javascript file,


additional code in between the script tags ________.
A) will be processed first
B) will be processed last
C) will be ignored
D) will be processed instead

Question # 32 (Multiple Choice) IE stores cookies ________.


A) in one large file called cookies.txt
B) in a directory called "cookies"
C) in a temp file
D) in the c:\internet explorer\cookies directory

Question # 33 (True/False) Javascript is similar to HTML in that it is not


case-sensitive.
A) True
B) False

Question # 34 (True/False) Some people turn off their cookies because cookies
can inadvertently spread viruses.
A) True
B) False

Question # 35 (Multiple Choice) Clicking a mouse button, running out of memory,


and placing a cursor in a form field are all known as ________.
A) methods
B) functions
C) events
D) occurrences

Question # 36 (Multiple Choice) The following is an example of a ________


statement.
{
case "Oranges" :
document.write("Oranges are $0.59 a pound.<BR>");
break;
case "Apples" :
document.write("Apples are $0.32 a pound.<BR>");
5
JAVA SCRIPT
break;
case "Bananas" :
document.write("Bananas are $0.48 a pound.<BR>");
break;
case "Cherries" :
document.write("Cherries are $3.00 a pound.<BR>");
break;
default :
document.write("Sorry, we are out of " + i + ".<BR>");
}

A) do....while
B) break
C) switch
D) continue

Question # 37 (Multiple Choice) Which of the following is the highest in the


Javascript DOM?
A) layer
B) form
C) anchor
D) history

Question # 38 (True/False) Object-based means that it depends for functionality


on a collection of built-in objects.
A) True
B) False

Question # 39 (Multiple Choice) The following is a standard ________.


<A HREF = "yourlink.html" onMouseOver = "imgOn('img1')"
onMouseOut = "imgOff('img1')">
<IMG NAME = "img1" SRC = "image1off.gif"></A>

A) rollover textual hyperlink


B) rollover image hyperlink
C) moving image
D) hyperlink

Question # 40 (Multiple Choice) The target attribute value "_blank" ________.


A) opens a document named blank
B) opens a file in a frame named blank
C) opens a new browser window
D) opens on top of a frameset

Question # 41 (True/False) getDay() retrieves the integer value of the day of


the week(0-6).
A) True
B) False

Question # 42 (Multiple Choice) ________ relates the principal that some objects
cannot be used or referenced without referring to the parent, or container,
object.
A) Containership
6
JAVA SCRIPT
B) Inheritance
C) SOM
D) DOME

Question # 43 (Multiple Choice) Which of the following is used to insert a tab?


A) \t
B) \>
C) \tab
D) \tt

Question # 44 (Multiple Choice) Which of the following logical operators returns


true if either logical expression is true?
A) ^
B) !
C) ||
D) +

Question # 45 (Multiple Choice) Which of the following evaluates an argument to


determine if it is not a number?
A) isNan
B) isNull
C) isString
D) isBlank

Question # 46 (Multiple Choice) The checked property for the checkbox object
returns ________.
A) true or false
B) the value of the object
C) the name of the object
D) a string

Question # 47 (Multiple Choice) What would be the result of "232" + "2"?


A) 234
B) 2322
C) "232""2"
D) 232+2

Question # 48 (True/False) It is recommended that you do not place script tags


inside of TD tags.
A) True
B) False

Question # 49 (Multiple Choice) In the following code, line number ______locates


the image on the document.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
A) 1
B) 2
C) 3
D) 4
7
JAVA SCRIPT

Question # 50 (True/False) You can specify different language versions of


different scripts on one page.
A) True
B) False

Question # 51 (Multiple Choice) Which of the following comparison operators


returns true if the operands are not equal?
A) &&
B) ==
C) !=
D) @

Question # 52 (Multiple Choice) Functions are best described as a ________.


A) method
B) an object
C) series of commands
D) a variable

Question # 53 (Multiple Answer) Which of the following let you jump out of an
iterating loop?
A) abort
B) Q
C) break
D) continue

Question # 54 (Multiple Choice) What is the primary problem with the following
Javascript code?
<HTML>
<HEAD>
JavaScript Testing Page
<SCRIPT>
//The following code will be for the form
validation.
. . . make believe there is script here
</SCRIPT>
</HEAD>
<BODY></BODY>
</HTML>
A) The LANGUAGE="JavaScript" is missing from the script tag.
B) The comments are done incorrectly.
C) There is no form in the body
D) There is no title tag.

Question # 55 (Multiple Choice) Which of the following assignment operators


performs a left shift and assigns the result to the first operand?
A) &&
B) >>-
C) <<=
D) ||

8
JAVA SCRIPT

Correct Answers
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 ,
19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 ,
35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 ,
51 , 52 , 53 , 54 , 55
Question # 1 (Multiple Choice) Variables are declared in Javascript using which
of the following?
Answer: (B) var
BACK
Question # 2 (Multiple Choice) If x=3, then the statement y=x++ sets __________.
Answer: (A) y to 3, increments x to 4
BACK
Question # 3 (Multiple Choice) What property reveals the operating system of the
client computer?
Answer: (B) userAgent
BACK
Question # 4 (Multiple Choice) When using the "+" operator with two strings, the
effect can best be described as ________.
Answer: (D) concatenation
BACK
Question # 5 (Multiple Choice) Which of the following assignment operators
assigns the value of the second operand to the first operand?
Answer: (A) =
BACK
Question # 6 (Multiple Choice) ________ are the specific property that will be
used.
Answer: (D) Values
BACK
Question # 7 (Multiple Choice) ________ are the actions that the object property
can be made to perform, such as calculation or writing of text.
Answer: (C) Methods
BACK
Question # 8 (Multiple Choice) If you have a series of five alerts in a row,
which of the following will occur?
Answer: (B) Each will appear in the order they appear in the script, as the user
clicks through them one at a time.
BACK
Question # 9 (Multiple Answer) If a file has a "runtime error", it is most
likely caused by which of the following?
(B) Mismatched data types appear when functions called

(C) Undeclared variables located on the wrong side of assignment operators

BACK
Question # 10 (Multiple Choice) Which of the following bitwise operators flips
the bits of its operand?
Answer: (A) ~
BACK
Question # 11 (Multiple Choice) The location of cookies for Netscape is
________.
Answer: (B) cookies.txt
BACK
9
JAVA SCRIPT
Question # 12 (True/False) Scripts placed in the body of a web document are
processed before scripts placed in the head.
Answer: False
BACK
Question # 13 (Multiple Choice) Which of the following is possible in
Javascript?
Answer: (D) Preprocess data on the client before submission to the server.
BACK
Question # 14 (Multiple Choice) If you delete cookies.txt from your hard drive,
what will be the consequence?
Answer: (B) Another cookies.txt file will be created automatically.
BACK
Question # 15 (Multiple Choice) x/y is the same as ________.
Answer: (B) divides x by y
BACK
Question # 16 (Multiple Choice) Why would anyone choose to use cookies?
Answer: (C) store preferences of user
BACK
Question # 17 (Multiple Choice) What would be the results of
document.write(anyString.substring(4,7)) on "Netscape"?
Answer: (A) cap
BACK
Question # 18 (Multiple Choice) Which of the following is the highest in the
Javascript object model hierarchy?
Answer: (B) form
BACK
Question # 19 (Multiple Choice) firstName="John"
lastName="Doe"
fullname= firstName+lastName
In the code above, which of the following will be the result?
Answer: (B) JohnDoe
BACK
Question # 20 (Multiple Answer) Which of the following bitwise operations are
correct?
(B) 15&9 yields 9

(C) 15|9 yields 15

BACK
Question # 21 (Multiple Choice) Which command holds values in a named space of
memory?
Answer: (B) variable
BACK
Question # 22 (Multiple Answer) Alert boxes ________.
(A) annoy the user

(B) increase interaction with the web page

(D) can display the current value of a variable, making them excellent for
troubleshooting

BACK
Question # 23 (Multiple Choice) Which of the following bitwise operators returns
10
JAVA SCRIPT
a one in each bit position if bits of both operands are ones?
Answer: (B) &
BACK
Question # 24 (Multiple Choice) In the expression ("Hello," + "Mary"), the +
operator is ________.
Answer: (C) concatenation
BACK
Question # 25 (Multiple Choice) What version of Javascript was first supported
by Netscape browser?
Answer: (B) 2
BACK
Question # 26 (Multiple Choice) Which of the following is the most commonly used
Javascript version?
Answer: (A) 1.2
BACK
Question # 27 (Multiple Choice) The following dot notation is referring to which
object?

window.document.body.form.radio
Answer: (B) radio
BACK
Question # 28 (Multiple Choice) The following code is used to ________.
setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://your-site.com";
}

Answer: (C) break out of frames


BACK
Question # 29 (Multiple Answer) Which of the following is typically used to
troubleshoot Javascript?
(A) comments

(B) alert()

The alert box lets you know you've made it to a certain line in the script,
comments let you temporarily delete sections that may not be working properly.
BACK
Question # 30 (Multiple Choice) Which of the following is used to insert a
backslash?
Answer: (A) \\
BACK
Question # 31 (Multiple Choice) If you use an external Javascript file,
additional code in between the script tags ________.
Answer: (C) will be ignored
BACK
Question # 32 (Multiple Choice) IE stores cookies ________.
Answer: (B) in a directory called "cookies"
BACK
Question # 33 (True/False) Javascript is similar to HTML in that it is not
case-sensitive.
11
JAVA SCRIPT
Answer: False
BACK
Question # 34 (True/False) Some people turn off their cookies because cookies
can inadvertently spread viruses.
Answer: False
BACK
Question # 35 (Multiple Choice) Clicking a mouse button, running out of memory,
and placing a cursor in a form field are all known as ________.
Answer: (C) events
BACK
Question # 36 (Multiple Choice) The following is an example of a ________
statement.
{
case "Oranges" :
document.write("Oranges are $0.59 a pound.<BR>");
break;
case "Apples" :
document.write("Apples are $0.32 a pound.<BR>");
break;
case "Bananas" :
document.write("Bananas are $0.48 a pound.<BR>");
break;
case "Cherries" :
document.write("Cherries are $3.00 a pound.<BR>");
break;
default :
document.write("Sorry, we are out of " + i + ".<BR>");
}

Answer: (C) switch


BACK
Question # 37 (Multiple Choice) Which of the following is the highest in the
Javascript DOM?
Answer: (D) history
BACK
Question # 38 (True/False) Object-based means that it depends for functionality
on a collection of built-in objects.
Answer: True
BACK
Question # 39 (Multiple Choice) The following is a standard ________.
<A HREF = "yourlink.html" onMouseOver = "imgOn('img1')"
onMouseOut = "imgOff('img1')">
<IMG NAME = "img1" SRC = "image1off.gif"></A>

Answer: (B) rollover image hyperlink


BACK
Question # 40 (Multiple Choice) The target attribute value "_blank"________.
Answer: (C) opens a new browser window
BACK
Question # 41 (True/False) getDay() retrieves the integer value of the day of
the week(0-6).
Answer: True
BACK
12
JAVA SCRIPT
Question # 42 (Multiple Choice) ________ relates the principal that some objects
cannot be used or referenced without referring to the parent, or container,
object.
Answer: (A) Containership
BACK
Question # 43 (Multiple Choice) Which of the following is used to insert a tab?
Answer: (A) \t
BACK
Question # 44 (Multiple Choice) Which of the following logical operators returns
true if either logical expression is true?
Answer: (C) ||
BACK
Question # 45 (Multiple Choice) Which of the following evaluates an argument to
determine if it is not a number?
Answer: (A) isNan
BACK
Question # 46 (Multiple Choice) The checked property for the checkbox object
returns ________.
Answer: (A) true or false
BACK
Question # 47 (Multiple Choice) What would be the result of "232" + "2"?
Answer: (B) 2322
BACK
Question # 48 (True/False) It is recommended that you do not place script tags
inside of TD tags.
Answer: True
This is a well known bug. BACK
Question # 49 (Multiple Choice) In the following code, line number ______locates
the image on the document.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
Answer: (B) 2
BACK
Question # 50 (True/False) You can specify different language versions of
different scripts on one page.
Answer: True
BACK
Question # 51 (Multiple Choice) Which of the following comparison operators
returns true if the operands are not equal?
Answer: (C) !=
BACK
Question # 52 (Multiple Choice) Functions are best described as a ________.
Answer: (C) series of commands
BACK
Question # 53 (Multiple Answer) Which of the following let you jump out of an
iterating loop?
(C) break

(D) continue

13
JAVA SCRIPT
BACK
Question # 54 (Multiple Choice) What is the primary problem with the following
Javascript code?
<HTML>
<HEAD>
JavaScript Testing Page
<SCRIPT>
//The following code will be for the form
validation.
...make believe there is script here
</SCRIPT>
</HEAD>
<BODY></BODY>
</HTML>
Answer: (B) The comments are done incorrectly.
BACK
Question # 55 (Multiple Choice) Which of the following assignment operators
performs a left shift and assigns the result to the first operand?
Answer: (C) <<=
BACK

Javascript Practice Quiz 2Javascript Practice Quiz 2


This is a self-grading exam. Answers are entered by clicking the button
corresponding to your selection. The examination is scored by clicking 'Grade
Test' at the bottom of the form. Correct answers and explanations are found
through hyperlinks at the bottom of the page. You may bypass taking the
examination and simply view the answers by clicking the answer hyperlinks.

Question # 1 (Multiple Choice) What is Javascript's default object?


A) navigator
B) document
C) window
D) browser

Question # 2 (Multiple Choice) ________ represent various attributes such as


height, color, font-size, sentence length, and so on.
A) Values
B) Properties
C) Functions
D) Descriptors

Question # 3 (True/False) All functions should be in the head section of the web
document.
A) True
B) False

Question # 4 (Multiple Choice) Which of the following logical operators returns


true if both logical operands are true?
A) &&
B) ++
14
JAVA SCRIPT
C) !
D) %

Question # 5 (Multiple Answer) Which of the following should be avoided in


Javascript for increased accessibility by the disabled?
A) onMouseover
B) onBlur
C) onAbort
D) use of functions
E) pop up windows

Question # 6 (Multiple Choice) The following shorthand x+=y is the same as


________.
A) x+1=y
B) 1=y
C) x=x+y
D) xy+1=y

Question # 7 (Multiple Choice) ECMA script most closely resembles Javascript


________.
A) 1.2
B) 1.1
C) 1.3
D) 1.5

Question # 8 (Multiple Choice) The target attribute value "blank"________.


A) opens a document named blank
B) opens a file in a frame named blank
C) opens a new browser window
D) opens on top of a frameset

Question # 9 (Multiple Choice) Each pass through a loop is called a/n ________.
A) switch
B) repeater
C) iteration
D) batch

Question # 10 (Multiple Choice) Why are Javascript commands contained within


HTML comment tags?
A) So commands won't display in non-javascript enabled browsers.
B) So search engines will not consider commands keywords.
C) Javascript will not execute without them.
D) The additional tags make the script more readable.

Question # 11 (Multiple Choice) The first slot in an array has an indexed number
of ________.
A) 0
B) 1
C) 101
D) There is not enough information to answer this question.

Question # 12 (Multiple Choice) Javascript is considered ________ scripting.


A) client-side
15
JAVA SCRIPT
B) server-side
C) operating system
D) programming

Question # 13 (Multiple Choice) Which of the following is used to insert a


carriage return?
A) \r
B) \\
C) \backspace
D) \new
E) \t

Question # 14 (Multiple Choice) Which of the following bitwise operators shifts


its first operand in binary representation the number of bits to the left
specified in the second operand, shifting in zeros from the right?
A) @2
B) -2
C) &&
D) <<

Question # 15 (Multiple Choice) Which of the following is used to insert a new


line?
A) \new
B) \n
C) \r
D) \return

Question # 16 (True/False) document.textField and document["textField"] are both


valid ways to refer to the same object.
A) True
B) False

Question # 17 (True/False) The confirm() method returns a value of true or


false.
A) True
B) False

Question # 18 (Multiple Choice) Which of the following adds one to a variable


representing a number?
A) ++
B) +
C) $
D) @

Question # 19 (Multiple Choice) In the expression (3*4), the * operator is


________.
A) addition
B) multiplication
C) concatenation
D) protected

Question # 20 (Multiple Choice) Which of the following shows proper syntax for
declaring an array?
16
JAVA SCRIPT
A) months = array("Jan","Feb","Mar")
B) array = months("Jan","Feb","Mar")
C) months = new array("Jan","Feb","Mar")
D) array months("Jan","Feb","Mar")

Question # 21 (Multiple Choice) In the following code, line number ______


contains the name of the function and the argument num that we will pass when we
call the function.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
A) 1
B) 2
C) 3
D) 4

Question # 22 (Multiple Choice) Who designed and developed Javascript?


A) Sun
B) Netscape
C) Microsoft
D) ECMA

Question # 23 (True/False) The language attribute in the script tag is optional.

A) True
B) False

Question # 24 (Multiple Answer) Which of the following are proper variable


names?
A) default
B) _first Text
C) firstText
D) 1stText
E) _var

Question # 25 (Multiple Choice) What version of Javascript was first supported


by Internet Explorer?
A) 1
B) 2
C) 3
D) 4

Question # 26 (Multiple Choice) Which of the following are not Javascript


reserved words?
A) import
B) super
C) public
D) first

Question # 27 (Multiple Choice) The following _________.


function confirm(){
17
JAVA SCRIPT
if (confirm("Do you hold us harmless from all legal action? "))
location="http://www.xxx.com";return " "}
document.writeln(confirm())

A) sends you to xxx.com if you click ok


B) requires you to sign a legal document
C) will easily crash your browser
D) is not legal if you have your Javascript turned off in your browser

Question # 28 (Multiple Choice) How many cookies are allowed per domain?
A) It depends on the domain extension (com vs. gov).
B) 1
C) 1 in IE, 20 in Netscape
D) It depends on the expiration dates.

Question # 29 (Multiple Choice) The following code writes _________.


str1="The morning is upon us. "
str2="The sun is bright."
str3=str1.concat(str2)
document.write(str3)

A) The sun is bright.


B) The morning is upon us.
C) null
D) The morning is upon us. The sun is bright.

Question # 30 (Multiple Choice) Which of the following is used to insert a


backspace?
A) \backspace
B) \n
C) \
D) <<

Question # 31 (Multiple Choice) Which of the following assignment operators adds


two numbers and assigns the result to the first?
A) +=
B) &&
C) *%
D) ##

Question # 32 (Multiple Choice) The root level of the DOM is ________.


A) browser
B) history
C) window
D) document

Question # 33 (Multiple Choice) The statement 3 + 3 + "3" will result in which


of the following?
A) 3
B) 63
C) 33
D) 9

18
JAVA SCRIPT
Question # 34 (Multiple Answer) Which of the following is not an event handler?
A) onDragDrop
B) onError
C) onScroll
D) onKeyup
E) onRoute

Question # 35 (Multiple Choice) ________ terminates the current while or for


loop and transfers program control to the statement following the terminated
loop.
A) Terminate
B) Return
C) Switch
D) Break

Question # 36 (Multiple Choice) Which of the following is a method?


A) array
B) boolean
C) object
D) prompt()

Question # 37 (True/False) getMonth() retrieves the month name (January,


February, etc.).
A) True
B) False

Question # 38 (Multiple Answer) What are some of the common benefits of form
field validation?
A) faster browser loading
B) increased user satisfaction
C) validity of form submission
D) increased security
E) faster server processing

Question # 39 (Multiple Choice) What is the purpose of the noscript tag?


A) Hides text from older browsers.
B) Display info for browsers that have Javascript turned off.
C) Temporarily ignore Javascript passages.
D) Display line numbers in the script.

Question # 40 (Multiple Choice) Javascript's original name was ________.


A) java
B) jscript
C) livescript
D) actionscript

Question # 41 (True/False) Javascript is object-based and Java is


object-oriented.
A) True
B) False

Question # 42 (Multiple Choice) If the system root is on drive c:, the location
of cookies for IE is ________.
19
JAVA SCRIPT
A) c:\windows\cookies
B) cookies.txt
C) c:\windows\system\cookies
D) c:\cookies

Question # 43 (Multiple Choice) If x=3, then the statement y=++x sets


__________.
A) y to 4, increments x to 4
B) y to 3, increments x to 4
C) y to 5, increments x to 5
D) It is impossible to determine this.

Question # 44 (Multiple Choice) Netscape ________.


A) appends cookies into one large file called cookies.exe
B) stores each cookie in its own .txt file in the cookies directory
C) stores each cookie in its own .txt file in the system directory
D) appends cookies into one large file called cookies.txt

Question # 45 (Multiple Choice) Which of the following syntax is correct for


commenting multiple lines in Javascript?
A) //
B) /* Comments */
C) ::
D) <!-- Comments -->

Question # 46 (True/False) JavaScript variables are loosely typed, meaning that


any variable can represent both a string of characters and a number, depending
solely upon what was assigned.
A) True
B) False

Question # 47 (Multiple Choice) The following returns ________.


function square(i) {
document.write("The call passed ", i ," to the function.","<BR>")
return i * i } document.write("The function returned ",square(2),".")

A) 2
B) 4
C) 1
D) It is impossible to say.

Question # 48 (Multiple Choice) External Javascript files have a ________


extension.
A) .ext
B) .jscript
C) .txt
D) .js
E) .htm

Question # 49 (Multiple Choice) Which of the following comparison operators


returns true if the operands are equal?
A) ==
B) !=
20
JAVA SCRIPT
C) &
D) ^

Question # 50 (Multiple Choice) Comparison operators ________.


A) return a value
B) return true or false
C) assign values
D) create more errors than assignment operators

Question # 51 (True/False) The Javascript object hierarchy model is divided into


3 parts: browser objects, language objects, and form field objects.
A) True
B) False

Question # 52 (Multiple Choice) Form text field validation ________.


A) can check if email addresses are correct
B) can check if the field is empty
C) can check if the password is correct
D) can check if credit cards are stolen

Question # 53 (Multiple Choice) Which of the following bitwise operators returns


a one in a bit if bits of either operand is one?
A) *
B) $
C) |
D) %

Question # 54 (Multiple Choice) Which of the following is used to display text


in a browser window using Javascript?
A) print "Hello, World"
B) window.print
C) document.print
D) document.write("Hello, World!")

Question # 55 (Multiple Choice) The following code ________ when the user clicks
the button.
<form>
<p><font face="MS Sans Serif"><input TYPE="Button" VALUE="Back up"
onClick="history.go(-1);"> </font></p>
</form>
A) goes back one page
B) goes back two pages
C) reloads the page
D) It is impossible to say without knowing the prior history.

Correct Answers
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 ,
19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 ,
35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 ,
51 , 52 , 53 , 54 , 55
21
JAVA SCRIPT
Question # 1 (Multiple Choice) What is Javascript's default object?
Answer: (C) window
BACK
Question # 2 (Multiple Choice) ________ represent various attributes such as
height, color, font-size, sentence length, and so on.
Answer: (B) Properties
BACK
Question # 3 (True/False) All functions should be in the head section of the web
document.
Answer: True
BACK
Question # 4 (Multiple Choice) Which of the following logical operators returns
true if both logical operands are true?
Answer: (A) &&
BACK
Question # 5 (Multiple Answer) Which of the following should be avoided in
Javascript for increased accessibility by the disabled?
(A) onMouseover

(E) pop up windows

BACK
Question # 6 (Multiple Choice) The following shorthand x+=y is the same as
________.
Answer: (C) x=x+y
BACK
Question # 7 (Multiple Choice) ECMA script most closely resembles Javascript
________.
Answer: (B) 1.1
BACK
Question # 8 (Multiple Choice) The target attribute value "blank"________.
Answer: (B) opens a file in a frame named blank
BACK
Question # 9 (Multiple Choice) Each pass through a loop is called a/n ________.
Answer: (C) iteration
BACK
Question # 10 (Multiple Choice) Why are Javascript commands contained within
HTML comment tags?
Answer: (A) So commands won't display in non-javascript enabled browsers.
BACK
Question # 11 (Multiple Choice) The first slot in an array has an indexed number
of ________.
Answer: (A) 0
BACK
Question # 12 (Multiple Choice) Javascript is considered ________ scripting.
Answer: (A) client-side
BACK
Question # 13 (Multiple Choice) Which of the following is used to insert a
carriage return?
Answer: (A) \r
BACK
Question # 14 (Multiple Choice) Which of the following bitwise operators shifts
its first operand in binary representation the number of bits to the left
22
JAVA SCRIPT
specified in the second operand, shifting in zeros from the right?
Answer: (D) <<
BACK
Question # 15 (Multiple Choice) Which of the following is used to insert a new
line?
Answer: (B) \n
BACK
Question # 16 (True/False) document.textField and document["textField"] are both
valid ways to refer to the same object.
Answer: True
BACK
Question # 17 (True/False) The confirm() method returns a value of true or
false.
Answer: True
BACK
Question # 18 (Multiple Choice) Which of the following adds one to a variable
representing a number?
Answer: (A) ++
BACK
Question # 19 (Multiple Choice) In the expression (3*4), the * operator is
________.
Answer: (B) multiplication
BACK
Question # 20 (Multiple Choice) Which of the following shows proper syntax for
declaring an array?
Answer: (C) months = new array("Jan","Feb","Mar")
BACK
Question # 21 (Multiple Choice) In the following code, line number ______
contains the name of the function and the argument num that we will pass when we
call the function.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
Answer: (A) 1
BACK
Question # 22 (Multiple Choice) Who designed and developed Javascript?
Answer: (B) Netscape
BACK
Question # 23 (True/False) The language attribute in the script tag is optional.
Answer: True
BACK
Question # 24 (Multiple Answer) Which of the following are proper variable
names?
(C) firstText

(E) _var

BACK
Question # 25 (Multiple Choice) What version of Javascript was first supported
by Internet Explorer?
Answer: (C) 3
23
JAVA SCRIPT
BACK
Question # 26 (Multiple Choice) Which of the following are not Javascript
reserved words?
Answer: (D) first
BACK
Question # 27 (Multiple Choice) The following _________.
function confirm(){if (confirm("Do you hold us harmless from all legal action?
"))
location="http://www.xxx.com";return " "}
document.writeln(confirm())

Answer: (A) sends you to xxx.com if you click ok


BACK
Question # 28 (Multiple Choice) How many cookies are allowed per domain?
Answer: (C) 1 in IE, 20 in Netscape
BACK
Question # 29 (Multiple Choice) The following code writes _________.
str1="The morning is upon us. "
str2="The sun is bright."
str3=str1.concat(str2)
document.write(str3)

Answer: (D) The morning is upon us. The sun is bright.


BACK
Question # 30 (Multiple Choice) Which of the following is used to insert a
backspace?
Answer: (A) \backspace
BACK
Question # 31 (Multiple Choice) Which of the following assignment operators adds
two numbers and assigns the result to the first?
Answer: (A) +=
BACK
Question # 32 (Multiple Choice) The root level of the DOM is ________.
Answer: (D) document
BACK
Question # 33 (Multiple Choice) The statement 3 + 3 + "3" will result in which
of the following?
Answer: (B) 63
BACK
Question # 34 (Multiple Answer) Which of the following is not an event handler?
(C) onScroll

(E) onRoute

BACK
Question # 35 (Multiple Choice) ________ terminates the current while or for
loop and transfers program control to the statement following the terminated
loop.
Answer: (D) Break
BACK
Question # 36 (Multiple Choice) Which of the following is a method?
Answer: (D) prompt()
BACK
24
JAVA SCRIPT
Question # 37 (True/False) getMonth() retrieves the month name (January,
February, etc.).
Answer: False
Retrieves values #0-11 BACK
Question # 38 (Multiple Answer) What are some of the common benefits of form
field validation?
(B) increased user satisfaction

(C) validity of form submission

(D) increased security

BACK
Question # 39 (Multiple Choice) What is the purpose of the noscript tag?
Answer: (B) Display info for browsers that have Javascript turned off.
BACK
Question # 40 (Multiple Choice) Javascript's original name was ________.
Answer: (C) livescript
BACK
Question # 41 (True/False) Javascript is object-based and Java is
object-oriented.
Answer: True
BACK
Question # 42 (Multiple Choice) If the system root is on drive c:, the location
of cookies for IE is ________.
Answer: (A) c:\windows\cookies
BACK
Question # 43 (Multiple Choice) If x=3, then the statement y=++x sets
__________.
Answer: (A) y to 4, increments x to 4
BACK
Question # 44 (Multiple Choice) Netscape ________.
Answer: (D) appends cookies into one large file called cookies.txt
BACK
Question # 45 (Multiple Choice) Which of the following syntax is correct for
commenting multiple lines in Javascript?
Answer: (B) /* Comments */
BACK
Question # 46 (True/False) JavaScript variables are loosely typed, meaning that
any variable can represent both a string of characters and a number, depending
solely upon what was assigned.
Answer: True
BACK
Question # 47 (Multiple Choice) The following returns ________.
function square(i) {
document.write("The call passed ", i ," to the function.","<BR>")
return i * i } document.write("The function returned ",square(2),".")

Answer: (B) 4
BACK
Question # 48 (Multiple Choice) External Javascript files have a ________
extension.
Answer: (D) .js
25
JAVA SCRIPT
BACK
Question # 49 (Multiple Choice) Which of the following comparison operators
returns true if the operands are equal?
Answer: (A) ==
BACK
Question # 50 (Multiple Choice) Comparison operators ________.
Answer: (B) return true or false
BACK
Question # 51 (True/False) The Javascript object hierarchy model is divided into
3 parts: browser objects, language objects, and form field objects.
Answer: True
BACK
Question # 52 (Multiple Choice) Form text field validation ________.
Answer: (B) can check if the field is empty
BACK
Question # 53 (Multiple Choice) Which of the following bitwise operators returns
a one in a bit if bits of either operand is one?
Answer: (C) |
BACK
Question # 54 (Multiple Choice) Which of the following is used to display text
in a browser window using Javascript?
Answer: (D) document.write("Hello, World!")
BACK
Question # 55 (Multiple Choice) The following code ________ when the user clicks
the button.
<form>
<p><font face="MS Sans Serif"><input TYPE="Button" VALUE="Back up"
onClick="history.go(-1);"> </font></p>
</form>
Answer: (A) goes back one page
BACK

CIWSS - Javascript Practice TestJavascript Practice Test


This is a self-grading exam. Answers are entered by clicking the button
corresponding to your selection. The examination is scored by clicking 'Grade
Test' at the bottom of the form. Correct answers and explanations are found
through hyperlinks at the bottom of the page. You may bypass taking the
examination and simply view the answers by clicking the answer hyperlinks.

You can buy the full version of this test for $15 for 110 questions by clicking
on the PayPal link. If you need to pay by some other means, go to the payment
page for other instructions.

It is much more cost efficient to JOIN CIW Study Site for $29.95. After joining,
members have access to over 1200 questions in the Designer, Developer and Server
Administrator tracks. You also get additional study materials.

26
JAVA SCRIPT
Question # 1 (Multiple Choice) Which of the following comparison operators
returns true if the operands are not equal?
A) &&
B) ==
C) !=
D) @

Question # 2 (Multiple Choice) Which of the following is the most commonly used
Javascript version?
A) 1.2
B) 1.3
C) 1.4
D) 1.5

Question # 3 (Multiple Choice) ________ relates the principal that some objects
cannot be used or referenced without referring to the parent, or container,
object.
A) Containership
B) Inheritance
C) SOM
D) DOME

Question # 4 (Multiple Choice) In the following code, line number ______


contains the name of the function and the argument num that we will pass when we
call the function.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
A) 1
B) 2
C) 3
D) 4

Question # 5 (Multiple Answer) Which of the following let you jump out of an
iterating loop?
A) abort
B) Q
C) break
D) continue

Question # 6 (Multiple Choice) Functions are best described as a ________.


A) method
B) an object
C) series of commands
D) a variable

Question # 7 (Multiple Choice) Which of the following logical operators returns


true if either logical expression is true?
A) ^
B) !
C) ||
27
JAVA SCRIPT
D) +

Question # 8 (Multiple Answer) Which of the following are proper variable names?

A) default
B) _first Text
C) firstText
D) 1stText
E) _var

Question # 9 (Multiple Choice) Javascript's original name was ________.


A) java
B) jscript
C) livescript
D) actionscript

Question # 10 (Multiple Choice) Which of the following bitwise operators flips


the bits of its operand?
A) ~
B) &
C) ^
D) %

Question # 11 (Multiple Choice) Which of the following is a method?


A) array
B) boolean
C) object
D) prompt()

Question # 12 (Multiple Choice) Variables are declared in Javascript using which


of the following?
A) dim
B) var
C) function
D) variable

Question # 13 (Multiple Choice) Which of the following is used to insert a


backspace?
A) \backspace
B) \n
C) \
D) <<

Question # 14 (Multiple Answer) Which of the following should be avoided in


Javascript for increased accessibility by the disabled?
A) onMouseover
B) onBlur
C) onAbort
D) use of functions
E) pop up windows

Question # 15 (Multiple Choice) What is Javascript's default object?


A) navigator
28
JAVA SCRIPT
B) document
C) window
D) browser

Question # 16 (Multiple Choice) Which of the following syntax is correct for


commenting multiple lines in Javascript?
A) //
B) /* Comments */
C) ::
D) <!-- Comments -->

Question # 17 (Multiple Answer) Which of the following bitwise operations are


correct?
A) 15^9 yields 8
B) 15&9 yields 9
C) 15|9 yields 15
D) 15&9 yields 15

Question # 18 (Multiple Choice) ________ are the actions that the object
property can be made to perform, such as calculation or writing of text.
A) Functions
B) Event handlers
C) Methods
D) Operations

Question # 19 (Multiple Choice) Which of the following is used to insert a new


line?
A) \new
B) \n
C) \r
D) \return

Question # 20 (Multiple Choice) The following _________.


function confirm(){if (confirm("Do you hold us harmless from all legal action?
"))
location="http://www.xxx.com";return " "}
document.writeln(confirm())

A) sends you to xxx.com if you click ok


B) requires you to sign a legal document
C) will easily crash your browser
D) is not legal if you have your Javascript turned off in your browser

Correct Answers
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 ,
19 , 20
Question # 1 (Multiple Choice) Which of the following comparison operators
returns true if the operands are not equal?
Answer: (C) !=
BACK
29
JAVA SCRIPT
Question # 2 (Multiple Choice) Which of the following is the most commonly used
Javascript version?
Answer: (A) 1.2
BACK
Question # 3 (Multiple Choice) ________ relates the principal that some objects
cannot be used or referenced without referring to the parent, or container,
object.
Answer: (A) Containership
BACK
Question # 4 (Multiple Choice) In the following code, line number ______
contains the name of the function and the argument num that we will pass when we
call the function.
1. function rollOn(num){
2. if(document.images){
3. eval('document.images["norm'+num+'"].src
4. ='+'over[num].src')}
5. }
Answer: (A) 1
BACK
Question # 5 (Multiple Answer) Which of the following let you jump out of an
iterating loop?
(C) break

(D) continue

BACK
Question # 6 (Multiple Choice) Functions are best described as a ________.
Answer: (C) series of commands
BACK
Question # 7 (Multiple Choice) Which of the following logical operators returns
true if either logical expression is true?
Answer: (C) ||
BACK
Question # 8 (Multiple Answer) Which of the following are proper variable names?
(C) firstText

(E) _var

BACK
Question # 9 (Multiple Choice) Javascript's original name was ________.
Answer: (C) livescript
BACK
Question # 10 (Multiple Choice) Which of the following bitwise operators flips
the bits of its operand?
Answer: (A) ~
BACK
Question # 11 (Multiple Choice) Which of the following is a method?
Answer: (D) prompt()
BACK
Question # 12 (Multiple Choice) Variables are declared in Javascript using which
of the following?
Answer: (B) var
BACK
30
JAVA SCRIPT
Question # 13 (Multiple Choice) Which of the following is used to insert a
backspace?
Answer: (A) \backspace
BACK
Question # 14 (Multiple Answer) Which of the following should be avoided in
Javascript for increased accessibility by the disabled?
(A) onMouseover

(E) pop up windows

BACK
Question # 15 (Multiple Choice) What is Javascript's default object?
Answer: (C) window
BACK
Question # 16 (Multiple Choice) Which of the following syntax is correct for
commenting multiple lines in Javascript?
Answer: (B) /* Comments */
BACK
Question # 17 (Multiple Answer) Which of the following bitwise operations are
correct?
(B) 15&9 yields 9

(C) 15|9 yields 15

BACK
Question # 18 (Multiple Choice) ________ are the actions that the object
property can be made to perform, such as calculation or writing of text.
Answer: (C) Methods
BACK
Question # 19 (Multiple Choice) Which of the following is used to insert a new
line?
Answer: (B) \n
BACK
Question # 20 (Multiple Choice) The following _________.
function confirm(){if (confirm("Do you hold us harmless from all legal action?
"))
location="http://www.xxx.com";return " "}
document.writeln(confirm())

Answer: (A) sends you to xxx.com if you click ok


BACK

31

Vous aimerez peut-être aussi