Your browser does not support JavaScript. You will need to view non-JavaScript portions of this page.

COP 2822: Fall Term 2003 On-Line Quizzes

In order to forward you your test results please enter your name & email address below:

Enter First Name followed by a space then your Last Name here:


Enter E-mail Address here:



Tutorial Four:
Decision Making with Control Structures and Statements

Chapter 4 Quiz Masters:

Marcelle Bessman (mbessma@ju.edu) [Text Input]

John Taylor (jtaylor@hcc.cc.fl.us) [Consultant]


Multiple Choice [One Answer Only]

Please Note that this test was prepared for the first edition of the text and it may have errors. Please note all errors in the: I have discovered that...Section below.

Question 1

Which of the following statements most accurately defines the syntax of an if statement?

a) The keyword if, a conditional expression in parentheses, square brackets, and executable statement.
b) The keyword if, a conditional expression in parentheses, and executable statements possibly inside curly braces.
c) The keyword if, a conditional expression in curly braces, and executable statements.
d) The keyword if, a conditional expression without parentheses, and executable statements.


Question 2

An iteration is

a) a comment statement
b) an instance of an object
c) an internal JavaScript function
d) one repetition of a loop statement


Question 3

Which of the following statements contains the proper syntax for an if statement?

a) if (x==2) then myvalue = 5;
b) if (x==2), myvalue = 5;
c) if (x==2)[myvalue=5];
d) if (x==2) myvalue = 5;


Question 4

The if statement is used to execute specific programming statements if an evaluated expression returns

a) a value of true
b) a value of false
c) a value of zero
d) none of the above


Question 5

When an if statement block must execute more than one programming statement, all of the executable statements must be

a) contained within square brackets
b) contained within parentheses
c) contained within curly braces
d) defined on the same line


Question 6

The types of operators that can be used with an if statement are _________and logical.

a) arithmetic
b) assignment
c) string
d) comparison


Question 7

What is wrong with the following if statement?
if(x = 2)
    myvalue = x;

a) the "myvalue = x" must be in curly braces
b) the "myvalue = x" must be in parentheses
c) the conditional statement uses the assignment operator instead of the comparison operator
d) none of the above, the statement is correct


Question 8

An if statement can include an alternate block of code to execute if the expression evaluates to false by including a(n)

a) if false statement
b) else clause
c) when false statement
d) then do clause


Question 9

The correct syntax for an else clause is shown by which of the following statements?

a) else (myvalue = 5);
b) else [myvalue = 5];
c) else {myvalue = 5};
d) else myvalue = 5;


Question 10

A(n) ______ if statement is one that is contained within an if or if...else statement.

a) embedded
b) related
c) nested
d) subordinate


Question 11

Nested if or if...else statements are coded to

a) increase the programs complexity
b) perform multiple conditional evaluations
c) decrease processing time
d) all of the above


Question 12

What would cause an else clause in an if...else statement to be executed?

a) The conditional expression evaluates to true.
b) The conditional expression evaluates to false.
c) The conditional expression cannot be interpreted by JavaScript
d) It will always execute as soon as the if statement finishes executing


Question 13

The maximum number of nested if statements is

a) 2
b) 5
c) 10
d) unlimited


Question 14

A JavaScript statement that executes a specific set of statements based on the value of an expression is the _____ statement.

a) break
b) if...or
c) switch
d) if...then


Question 15

Specific code segments within a switch statement are identified by

a) case labels
b) switch labels
c) question marks
d) begin statements


Question 16

If a switch statement expression is evaluated and does not match any of the case labels, the switch statement can still execute a block of code if the _____ label is defined.

a) nomatch
b) default
c) altcase
d) dowhen


Question 17

Which of the following statements shows the proper syntax for defining a While loop?

a) while {(conditional expression) then statements};
b) while (conditional expression, counter variable) {statements;}
c) while (conditional expression, statements);
d) while (conditional expression){statements;}


Question 18

A while statement is a loop statement that executes as long as

a) a specific condition is true
b) a specific condition is false
c) a counter has not reached its terminating value
d) none of the above


Question 19

A variable that either increments or decrements its value with each cycle through a loop statement is a(n)

a) repeater
b) counter
c) terminator
d) accumulator


Question 20

What will be the result of executing the following while statement?
var count = 10;
while (count > 0)
   document.writeln(count);

a) The loop will repeat 10 times and print the values 10, 9, 8, etc.
b) It will not execute because there is a syntax error
c) This will statement will cause an infinite loop
d) It will execute 10 times and print the values 1, 2, 3, etc.


Question 21

What is the primary difference between a while loop and a do...while loop?

a) Nothing - they function the same
b) A while loop always executes its loop statements at least once
c) The do...while loop executes while a condition is false
d) The do...while loop always executes at least once


Question 22

Which of the following statements is the correct syntax for defining a do...while loop?

a) do {statements,} while (conditional expressions);
b) do while {statements; (conditional expression};
c) do (conditional expression {statements;} while (true);
d) {statements;} do while (conditional expression);


Question 23

How many times will the following do while loop execute?
var count = 0;
do { document.writeln(count);
   count += 7;
}while(count < 7);

a) It will not execute because there is a syntax error
b) This do...while loop will cause an infinite loop
c) It will execute twice
d) It will execute only one time


Question 24

How does the syntax for a ";for" loop statement differ from a "while"

a) The syntax is essentially the same
b) The for statement itself can contain code to initialize and increment/decrement its counter variable
c) The while statement itself can contain code to initialize and increment/decrement its counter variable
d) The for statement executes while the given condition is false


Question 25

When is a for statement's counter incremented or decremented?

a) When the condition begin evaluated becomes false
b) At the beginning of every iteration
c) At the end of every iteration
d) Immediately after it is initialized


Question 26

Which of the following shows the correct syntax for the for...in statement?

a) for {(variable in object) statements;}
b) for (variable in property){statements;}
c) for (variable in object){statements;}
d) for (object in variable){statements;}


Question 27

One of the benefits of a for...in statement is that it assigns a(n) ______ to each property in an element.

a) index
b) default value
c) class
d) name


Question 28

The with statement give you the ability to reference the _____ of an object without having to type the object name in every statement.

a) class
b) descriptors
c) properties
d) field values


Question 29

Which of the following statements uses the correct syntax to define the with statement?

a) with{(object) statements;}
b) with(object, property){statements;}
c) with (object){statements;}
d) none of the above


Question 30

What would be the output printed by the following code when executed?
for (count = 1; count < 5; count++){
   if(count==3)
     continue;
document.write(count);

a) 1,2,3,4
b) 1,2,4
c)1,2
d)1,2,3




True/False Questions


Question 31

An if statement can be used to execute one or more program statements if an evaluated condition returns a value of false.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 32

Multiple program statements contained with a set of braces is a command block.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 33

When multiple program statements follow an if statement, they will all be executed if the conditional expression is true as long as all statements are indented the same distance.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 34

Multiple statements can be included for a case label without using braces to create a command block.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 35

The switch statement can include a default label to execute specific statements when none of the case labels match the evaluated expression.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 36

When a conditional expression is incorrectly defined, or never updated, it can case a loop statement to repeat infinitely.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 37

A do...while loop statement evaluates its conditional expression at the bottom of the loop, and therefore will always execute the included statements at least once.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 38

The counter variable used in a for statement is incremented/decremented at the end of every loop iteration, and the the conditional is evaluated again.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 39

The with statement allows you to reference the properties of an object without having to retype the object name on each line.

a) The statement above is TRUE.
b) The statement above is FALSE.



Question 40

You can stop a specific iteration of a looping statement but continue with the next iteration by using the break statement.

a) The statement above is TRUE.
b) The statement above is FALSE.




Fill-in-the-Blank


Fill in the Blank with the word(s) that best fits the definition:

(hint: use vocabulary from the checkboxes below)

Question 41. A (two words) refers to multiple statements contained within a set of braces, similar to the way a function's statements are contained within a set of braces.



Question 42. The process of determining the order in which statements execute in a program is called flow control or (two words).



Question 43. The statement is used to execute specific programming code if the evaluation of a conditional expression returns a value of true



Question 44. The statement controls program flow by executing a specific set of statements, depending on the value of the expression.



Question 45. The labels within a switch statement are called labels and they mark specific code segments.



Question 46. The label contains statements that execute when the value returned by the switch statement's conditional expression does not match a case label.



Question 47. A switch statement ends automatically after the JavaScript interpreter encounters its closing brace (}) or when a statement is found.



Question 48. A statement repeatedly executes a statement or a series of statements while a specific condition is true or until a specific condition becomes true: for example a while statement is a specific example.



Question 49. Every repetition of a loop statement is a(n) .



Question 50. The statement eliminates the need to retype an objects name on every statements that refers to its properties.






I have


Please add a comment below



The 'Muddy Water' Issues that I need help on are as follows:





I need class review on the following vocabulary words from this chapter:

decision making flow control if statement command block if...else statement

nested if statement nested if...else statement switch statement loop statement while statement

iteration counter infinite loop do...while statement for statement


for...in statement enumerates with statement continue statement break statement





When you have completed this quiz click the submit button (Those users whose Browser supports JavaScript) to send answers to your instructor

(This may takes a few moments to submit)


Click reset to clear all answers

Users whose browser does not support JavaScript, when you have completed this quiz click the submit button below to send answers to your instructor


Quiz Page was last modified by John Taylor: