Deck 20: Iteration Principles
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/52
Play
Full screen (f)
Deck 20: Iteration Principles
1
The control specification of the for loop includes three operations: <initialization>, <continuation>, and <next iteration> .
True
2
A for loop continues as long as the <continuation> test is true .
True
3
The starting point for a for loop is always 0 .
False
4
The step size of a for loop is always 1 .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
5
Loops cannot count backwards .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
6
Iteration variables must always be single letter identifiers .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
7
The iteration variable is often used in computations in the <statement list> .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
8
Iteration variables should be declared with the keyword iter instead of var because they are special variables .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
9
All for loops should have a <continuation> test .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
10
The <continuation> operation of a for loop has the same form as the predicate in a conditional statement .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
11
You can put a loop inside another loop .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
12
You cannot put a conditional statement inside a loop .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
13
An array index must be a non-negative integer .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
14
The off-by-one error is an uncommon error in computing .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
15
Image prefetching can be performed at any time prior to the start of the associated animation .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
16
If the loop initialization of a for loop makes the continuation test false, the loop body will only execute once .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
17
A World-Famous Iteration (WFI) loop which has n iterations generates exactly all the legal subscripts for an array of size n .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
18
Anything you can do by modifying the DOM could also be done with the document . write() function .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
19
Timers can be set but not canceled .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following controls the number of iterations of a for loop?
A) function
B) iteration variable
C) incrementization
D) initialization
A) function
B) iteration variable
C) incrementization
D) initialization
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
21
How many iterations will occur in the following loop?
For (again = 0; again < 5; again++) { . . . . }
A) six
B) five
C) four
D) cannot tell
For (again = 0; again < 5; again++) { . . . . }
A) six
B) five
C) four
D) cannot tell
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
22
For the elements of an array to store images, they must each be initialized to a(n)
A) prefetch object
B) src object
C) gifpix object
D) image object
A) prefetch object
B) src object
C) gifpix object
D) image object
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following will create a loop that will iterate ten times?
A) for (i = 0; i <=10; i = i + 1)
B) for (i = 1; i < 10; i = i + 1)
C) for (i = 0; i <10; i = i + 1)
D) None of these
A) for (i = 0; i <=10; i = i + 1)
B) for (i = 1; i < 10; i = i + 1)
C) for (i = 0; i <10; i = i + 1)
D) None of these
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following is an infinite loop?
A) for (k = 1; k <= 4; k = k + 1)
B) for (k = 1; k < 3; k = k + 1)
C) for (k = 0; k <= 10; k = k + 1)
D) for (k = 1; k <= 4; k = k - 1)
A) for (k = 1; k <= 4; k = k + 1)
B) for (k = 1; k < 3; k = k + 1)
C) for (k = 0; k <= 10; k = k + 1)
D) for (k = 1; k <= 4; k = k - 1)
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following is the correct code for the step size of the loop shown to ensure that the loop will repeat exactly five times?
For ( c = 3; c < 13; ________)
A) c = c + 2
B) c++
C) c = c + 3
D) c = c + 4
For ( c = 3; c < 13; ________)
A) c = c + 2
B) c++
C) c = c + 3
D) c = c + 4
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following is the correct way to declare an array named myArray with ten elements?
A) var myArray = new(10);
B) myArray = new var(10);
C) var myArray = new Array(10);
D) new myArray = Array(10);
A) var myArray = new(10);
B) myArray = new var(10);
C) var myArray = new Array(10);
D) new myArray = Array(10);
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following is the standard form for the World-Famous Iteration?
A) for (i = 0; i <= n; i++) { . . . }
B) for (i = 1; i < n; i++) { . . . }
C) for (i = 0; i < n; i++) { . . . }
D) None of these
A) for (i = 0; i <= n; i++) { . . . }
B) for (i = 1; i < n; i++) { . . . }
C) for (i = 0; i < n; i++) { . . . }
D) None of these
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following statements is TRUE about the following JavaScript declaration?var rows = new Array(5);
A) The array will have six items .
B) The first item in the array will be rows[0] .
C) The last item in the array will be rows[5] .
D) All of these are true .
A) The array will have six items .
B) The first item in the array will be rows[0] .
C) The last item in the array will be rows[5] .
D) All of these are true .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
29
In a for loop, the operation that sets the variable's value for the first iteration of the loop is the
A) initialization
B) test
C) condition
D) iteration
A) initialization
B) test
C) condition
D) iteration
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
30
The clearTimeout() function is used to
A) restart the timer
B) reset the interval of the timer
C) cancel the timer
D) reset the number of times the timer runs
A) restart the timer
B) reset the interval of the timer
C) cancel the timer
D) reset the number of times the timer runs
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
31
If you have a nested loop structure where the outside loop runs five times and the inside loops runs seven times, the statements of the inside loop will be executed ________ times .
A) seven
B) five
C) twelve
D) thirty-five
A) seven
B) five
C) twelve
D) thirty-five
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
32
On a web page, images can be loaded and stored in a(n)
A) image array
B) form load
C) image object
D) pic array
A) image array
B) form load
C) image object
D) pic array
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
33
Given the following JavaScript code, which of the following is the handle?
TimerID = setTimeout("animate()", 30);
ClearTimeout(timerID);
A) setTimeout()
B) clearTimeout()
C) clearTimeout(timerID)
D) timerID
TimerID = setTimeout("animate()", 30);
ClearTimeout(timerID);
A) setTimeout()
B) clearTimeout()
C) clearTimeout(timerID)
D) timerID
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
34
Given the following JavaScript code, which of the following is the event handler?
TimerID = setTimeout("animate()", 30);
ClearTimeout(timerID);
A) setTimeout()
B) animate()
C) setTimeout(animate())
D) timerID
TimerID = setTimeout("animate()", 30);
ClearTimeout(timerID);
A) setTimeout()
B) animate()
C) setTimeout(animate())
D) timerID
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
35
In programming ________ means looping through a series of statements to repeat them .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
36
The proper programming term for <continuation> is ________ test because it checks to see if the loop should terminate .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
37
The ________ size is the amount that an iteration variable is changed after each cycle of a for loop .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
38
In JavaScript '\n' is the ________ symbol .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
39
The point at which array indexing begins (the least index) is the index ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
40
The index origin in JavaScript is ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
41
A(n) ________ is an indexed base name .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
42
An array index is also called a(n) ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
43
In animation, one of many images that is rapidly redrawn to create the illusion of motion is known as a(n) ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
44
In JavaScript, i++ is an example of ________ notation and means the same as i = i + 1 .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
45
Loading images ahead of time is called ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
46
The number of elements in an array is referred to as the array ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
47
A(n) ________ is the common name for the repetition of a block of programming code .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
48
A(n) ________ is the single still image in a series of rapidly moving still images .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
49
In JavaScript, timers ________ a thousand times per second .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
50
If myArray is an array of length 10, the largest subscript is ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
51
A JavaScript program can change the content of a page that is already displayed by changing the ________ .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck
52
The timed event code that displays an animation must update the displayed frame and finally set the ________ so the next frame will be displayed .
Unlock Deck
Unlock for access to all 52 flashcards in this deck.
Unlock Deck
k this deck