Deck 8: Javascript: Control Statements II

Full screen (f)
exit full mode
Question
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
For ( var count = 0; count < 10; ++count )
{
If ( count == 5 )
Continue;
}
Document.writeln( count );
//-- >
< /script >

A) Nothing; the script would generate an error.
B) 5
C) 9
D) 10
Use Space or
up arrow
down arrow
to flip the card.
Question
In a switch statement, the ________ case clause is used to process exceptional conditions and is usually listed last.

A) break
B) default
C) else
D) then
Question
What is the value of num after the following statement is performed
Num = 2 * Math.pow( 2, 3 );

A) 16
B) 18
C) 64
D) 8
Question
Switch statements contain ________ labels.

A) select
B) if...else
C) case
D) choice
Question
The ________ multiple-selection statement is used to handle decision making and can be used to replace multiple if and if...else statements.

A) do...while
B) case
C) break
D) switch
Question
Consider the following code selections. Assume count is initialized to 7 and num is initialized to 0.
I) ii)
Do
{ while ( count < 6 )
Num = count; num = count;
} while ( count < 6 )
What will the value of num be for i) and ii) respectively after the loops have been executed

A) 0, 0
B) 0, 7
C) 7, 0
D) 7, 7
Question
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
For ( var count = 1; count < = 10; ++count )
{
If ( count == 5 )
Break;
}
Document.writeln( count );
//-- >
< /script >

A) Nothing; the script would generate an error.
B) 1
C) 5
D) 10
Question
Which of the following will not evaluate to true

A) false || false
B) true || true
C) false || true
D) true || false
Question
Which of the following will not evaluate to false

A) false && false
B) true && true
C) false && true
D) true && false
Question
What would the browser display if the following script were executed
< script type = "text/javascript" >
< !--
For ( var i = 0; i < 5; i++ )
Document.write( "O" );
//-- >
< /script >

A) Nothing; the script would generate an error
B) OOOO
C) OOOOO
D) OOOOOO
Question
Which of the following is not required for counter-controlled repetition

A) final value
B) initial value
C) sentinel
D) increment
Question
What is the value of num after the following statements are performed
Num = 2.4589;
Num = num.toFixed( 2 );

A) 2
B) 2.46
C) 2.5
D) 2.45
Question
What should you use as a counter in counter-controlled repetition

A) a floating-point number
B) a sentinel
C) an integer
D) a num object
Question
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
Var i = 0;
Do
{
Document.write( "O" );
I++;
} while ( i > 5 );
//-- >
< /script >

A) Nothing; the script would generate an error
B) O
C) OOOOO
D) OOOOOO
Question
What would the browser display if the following script were executed
< script type = "text/javascript" >
< !--
For ( var i = 0; var i < 5; var i++ )
Document.write( "X" );
//-- >
< /script >

A) Nothing; the script would generate an error
B) XXXX
C) XXXXX
D) XXXXXX
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/15
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 8: Javascript: Control Statements II
1
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
For ( var count = 0; count < 10; ++count )
{
If ( count == 5 )
Continue;
}
Document.writeln( count );
//-- >
< /script >

A) Nothing; the script would generate an error.
B) 5
C) 9
D) 10
D
2
In a switch statement, the ________ case clause is used to process exceptional conditions and is usually listed last.

A) break
B) default
C) else
D) then
B
3
What is the value of num after the following statement is performed
Num = 2 * Math.pow( 2, 3 );

A) 16
B) 18
C) 64
D) 8
A
4
Switch statements contain ________ labels.

A) select
B) if...else
C) case
D) choice
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
5
The ________ multiple-selection statement is used to handle decision making and can be used to replace multiple if and if...else statements.

A) do...while
B) case
C) break
D) switch
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
6
Consider the following code selections. Assume count is initialized to 7 and num is initialized to 0.
I) ii)
Do
{ while ( count < 6 )
Num = count; num = count;
} while ( count < 6 )
What will the value of num be for i) and ii) respectively after the loops have been executed

A) 0, 0
B) 0, 7
C) 7, 0
D) 7, 7
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
7
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
For ( var count = 1; count < = 10; ++count )
{
If ( count == 5 )
Break;
}
Document.writeln( count );
//-- >
< /script >

A) Nothing; the script would generate an error.
B) 1
C) 5
D) 10
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following will not evaluate to true

A) false || false
B) true || true
C) false || true
D) true || false
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following will not evaluate to false

A) false && false
B) true && true
C) false && true
D) true && false
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
10
What would the browser display if the following script were executed
< script type = "text/javascript" >
< !--
For ( var i = 0; i < 5; i++ )
Document.write( "O" );
//-- >
< /script >

A) Nothing; the script would generate an error
B) OOOO
C) OOOOO
D) OOOOOO
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is not required for counter-controlled repetition

A) final value
B) initial value
C) sentinel
D) increment
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
12
What is the value of num after the following statements are performed
Num = 2.4589;
Num = num.toFixed( 2 );

A) 2
B) 2.46
C) 2.5
D) 2.45
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
13
What should you use as a counter in counter-controlled repetition

A) a floating-point number
B) a sentinel
C) an integer
D) a num object
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
14
What would the browser display if it executed the following script
< script type = "text/javascript" >
< !--
Var i = 0;
Do
{
Document.write( "O" );
I++;
} while ( i > 5 );
//-- >
< /script >

A) Nothing; the script would generate an error
B) O
C) OOOOO
D) OOOOOO
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
15
What would the browser display if the following script were executed
< script type = "text/javascript" >
< !--
For ( var i = 0; var i < 5; var i++ )
Document.write( "X" );
//-- >
< /script >

A) Nothing; the script would generate an error
B) XXXX
C) XXXXX
D) XXXXXX
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 15 flashcards in this deck.