Deck 7: Javascript: Control Statements I

Full screen (f)
exit full mode
Question
Which of the following statements is correct

A) If ( studentGrade >= 60 ) document.writeln( "Passed" );
B) if ( studentGrade >= 60 ); document.writeln( "Passed" );
C) if ( studentGrade >= 60 ) document.write( "Passed" );
D) If ( studentGrade >= 60 ); document.write( "Passed" );
Use Space or
up arrow
down arrow
to flip the card.
Question
What would the browser display if the following code were executed in a script
Var x = 11;
Var y = 14;
If ( x > 13 )
If ( y > 13 )
Document.writeln( "x and y are > 13" );
Else
Document.writeln( "x is < = 13" );

A) nothing
B) 11
C) x and y are > 13
D) x is < = 13
Question
Which of the following flowchart symbols can represent an if statement

A) diamond
B) oval/circle
C) rectangle
D) flowline
Question
What would the browser display if the following code were executed in a script
Var product = 0;
While (product >= 25)
Product = 2 + product;
Document.writeln( product );

A) nothing, the script would result in an error
B) 0
C) 24
D) 26
Question
If the string passed to parseInt contains a floating-point numeric value, parseInt will ________.

A) return NaN
B) return 0
C) round the value to the nearest tenth
D) truncate the floating-point part to be left with an integer value
Question
If the string passed to parseInt contains text characters, parseInt will ________.

A) return NaN
B) return 0
C) return the sum of the characters' ASCII values
D) truncate the text entries
Question
Which of the following flowchart symbols indicates that a decision is to be made

A) diamond
B) oval/circle
C) rectangle
D) flowline
Question
What would the browser display if the following script were executed
< script type = "text/javascript" >
Var count = 0;
Var total = 0;
While ( count < = 5 )
{
Total = total + 10;
Count = count + 1;
}
Document.write( total );
< /script >

A) Nothing; the browser would generate an error.
B) 0
C) 50
D) 60
Question
What would the browser display if the following code were executed in a script
Var product = 0;
While ( product < = 25 );
Product = 2 + product;

A) nothing, the script would result in an inifite-loop error
B) 0
C) 25
D) 26
Question
________ is an informal language that helps programmers develop algorithms.

A) JavaScript
B) ECMAScript
C) Pseudocode
D) AlgorithmCode
Question
The word sequence in the term sequence structure refers to the sequence of ________.

A) bits in a JavaScript instruction
B) JavaScript instructions in a script
C) scripts in an HTML file
D) HTML files in a Web site
Question
Research determined that all programs could be written in terms of only three control structures. Which of the following is not one of the three control structures

A) goto-less structure
B) sequence structure
C) selection structure
D) repetition structure
Question
Which of the following is a JavaScript repetition statement

A) while...repeat
B) do...while
C) do...repeat
D) for...do
Question
Which of the following is not a JavaScript selection statement

A) if...else
B) for...in
C) switch
D) if
Question
Specifying the order in which programming statements are to be executed is called ________.

A) program control
B) a program structure
C) a control structure
D) an algorithm
Question
What would the browser display if the following code were executed in a script
Var grade = 59;
If ( grade >= 60 )
Document.writeln( "Passed." );
Else
Document.write( "Failed. " );
Document.writeln( "You must take this course again." );

A) Passed.
B) Failed.
C) You must take this course again.
D) Failed. You must take this course again.
Question
A program in which all statements are executed one after the other in the order in which they are written exhibits ________.

A) transfer of control
B) algorithms
C) sequential execution
D) direct execution
Question
A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called ________.

A) program control
B) a program structure
C) a control structure
D) an algorithm
Question
What would the browser display if the following script were executed
< script type = "text/javascript" >
Var count = 5;
Var total = 0;
While ( count > -1 )
{
Total = total - 10;
Count = count - 1;
}
Document.write( total );
< /script >

A) Nothing; the browser would generate an error.
B) 0
C) -50
D) -60
Question
Which of the following is not a JavaScript keyword

A) break
B) delete
C) sub
D) for
Question
The word top in the term top-down stepwise refinement refers to which of the following

A) the first statement that appears in the script
B) the first statement that appears in the algorithm
C) the single statement that completely represents the script
D) the entire algorithm
Question
What output will the following script produce
Var i = 0;
Var j = 3;
Var counter = 0;
While ( i < 5 )
{
If (i != j)
Counter = counter + i;
I = i + 1
}
Document.write( counter );

A) 9
B) 14
C) 3
D) 7
Question
What type of loop should be used in a script that processes test results for 150 students

A) counter controlled
B) sentinel controlled
C) algorithm controlled
D) stepwise controlled
Question
Which of the following is the correct abbreviation for the statement a = a * 7;

A) a =* 7;
B) a *= 7;
C) 7 =* a;
D) 7 *= a;
Question
What type of loop is shown in the script below
< script type = "text/javascript" >
Var gradeValue = 0,
Total = 0,
Grade = 0;
While ( gradeValue != - 1 )
{
Total = total + gradeValue;
Grade = window.prompt( "Enter Integer Grade, -1 to Quit:" , "0" );
GradeValue = parseInt( grade );
}
< /script >

A) counter controlled
B) sentinel controlled
C) algorithm controlled
D) stepwise controlled
Question
What is the value of i after the following statements
I = 2;
I--;
I--;

A) 0
B) 1
C) -2
D) -4
Question
What is the value of i after the following statements
I = 2;
I++;

A) 0
B) 2
C) 3
D) 4
Question
What is the output of the following script
I = 16;
Document.write( ++i );

A) 16
B) 17
C) 15
D) Nothing; the browser would generate an error.
Question
If the initial value of a is 15, what new value is assigned to a in the expression a %= 4

A) 2
B) 3
C) 4
D) 5
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/29
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Javascript: Control Statements I
1
Which of the following statements is correct

A) If ( studentGrade >= 60 ) document.writeln( "Passed" );
B) if ( studentGrade >= 60 ); document.writeln( "Passed" );
C) if ( studentGrade >= 60 ) document.write( "Passed" );
D) If ( studentGrade >= 60 ); document.write( "Passed" );
C
2
What would the browser display if the following code were executed in a script
Var x = 11;
Var y = 14;
If ( x > 13 )
If ( y > 13 )
Document.writeln( "x and y are > 13" );
Else
Document.writeln( "x is < = 13" );

A) nothing
B) 11
C) x and y are > 13
D) x is < = 13
A
3
Which of the following flowchart symbols can represent an if statement

A) diamond
B) oval/circle
C) rectangle
D) flowline
A
4
What would the browser display if the following code were executed in a script
Var product = 0;
While (product >= 25)
Product = 2 + product;
Document.writeln( product );

A) nothing, the script would result in an error
B) 0
C) 24
D) 26
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
5
If the string passed to parseInt contains a floating-point numeric value, parseInt will ________.

A) return NaN
B) return 0
C) round the value to the nearest tenth
D) truncate the floating-point part to be left with an integer value
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
6
If the string passed to parseInt contains text characters, parseInt will ________.

A) return NaN
B) return 0
C) return the sum of the characters' ASCII values
D) truncate the text entries
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following flowchart symbols indicates that a decision is to be made

A) diamond
B) oval/circle
C) rectangle
D) flowline
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
8
What would the browser display if the following script were executed
< script type = "text/javascript" >
Var count = 0;
Var total = 0;
While ( count < = 5 )
{
Total = total + 10;
Count = count + 1;
}
Document.write( total );
< /script >

A) Nothing; the browser would generate an error.
B) 0
C) 50
D) 60
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
9
What would the browser display if the following code were executed in a script
Var product = 0;
While ( product < = 25 );
Product = 2 + product;

A) nothing, the script would result in an inifite-loop error
B) 0
C) 25
D) 26
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
10
________ is an informal language that helps programmers develop algorithms.

A) JavaScript
B) ECMAScript
C) Pseudocode
D) AlgorithmCode
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
11
The word sequence in the term sequence structure refers to the sequence of ________.

A) bits in a JavaScript instruction
B) JavaScript instructions in a script
C) scripts in an HTML file
D) HTML files in a Web site
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
12
Research determined that all programs could be written in terms of only three control structures. Which of the following is not one of the three control structures

A) goto-less structure
B) sequence structure
C) selection structure
D) repetition structure
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is a JavaScript repetition statement

A) while...repeat
B) do...while
C) do...repeat
D) for...do
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is not a JavaScript selection statement

A) if...else
B) for...in
C) switch
D) if
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
15
Specifying the order in which programming statements are to be executed is called ________.

A) program control
B) a program structure
C) a control structure
D) an algorithm
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
16
What would the browser display if the following code were executed in a script
Var grade = 59;
If ( grade >= 60 )
Document.writeln( "Passed." );
Else
Document.write( "Failed. " );
Document.writeln( "You must take this course again." );

A) Passed.
B) Failed.
C) You must take this course again.
D) Failed. You must take this course again.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
17
A program in which all statements are executed one after the other in the order in which they are written exhibits ________.

A) transfer of control
B) algorithms
C) sequential execution
D) direct execution
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
18
A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called ________.

A) program control
B) a program structure
C) a control structure
D) an algorithm
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
19
What would the browser display if the following script were executed
< script type = "text/javascript" >
Var count = 5;
Var total = 0;
While ( count > -1 )
{
Total = total - 10;
Count = count - 1;
}
Document.write( total );
< /script >

A) Nothing; the browser would generate an error.
B) 0
C) -50
D) -60
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is not a JavaScript keyword

A) break
B) delete
C) sub
D) for
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
21
The word top in the term top-down stepwise refinement refers to which of the following

A) the first statement that appears in the script
B) the first statement that appears in the algorithm
C) the single statement that completely represents the script
D) the entire algorithm
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
22
What output will the following script produce
Var i = 0;
Var j = 3;
Var counter = 0;
While ( i < 5 )
{
If (i != j)
Counter = counter + i;
I = i + 1
}
Document.write( counter );

A) 9
B) 14
C) 3
D) 7
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
23
What type of loop should be used in a script that processes test results for 150 students

A) counter controlled
B) sentinel controlled
C) algorithm controlled
D) stepwise controlled
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following is the correct abbreviation for the statement a = a * 7;

A) a =* 7;
B) a *= 7;
C) 7 =* a;
D) 7 *= a;
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
25
What type of loop is shown in the script below
< script type = "text/javascript" >
Var gradeValue = 0,
Total = 0,
Grade = 0;
While ( gradeValue != - 1 )
{
Total = total + gradeValue;
Grade = window.prompt( "Enter Integer Grade, -1 to Quit:" , "0" );
GradeValue = parseInt( grade );
}
< /script >

A) counter controlled
B) sentinel controlled
C) algorithm controlled
D) stepwise controlled
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
26
What is the value of i after the following statements
I = 2;
I--;
I--;

A) 0
B) 1
C) -2
D) -4
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
27
What is the value of i after the following statements
I = 2;
I++;

A) 0
B) 2
C) 3
D) 4
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
28
What is the output of the following script
I = 16;
Document.write( ++i );

A) 16
B) 17
C) 15
D) Nothing; the browser would generate an error.
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
29
If the initial value of a is 15, what new value is assigned to a in the expression a %= 4

A) 2
B) 3
C) 4
D) 5
Unlock Deck
Unlock for access to all 29 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 29 flashcards in this deck.