CodeHS Animation And Games Practice Test

EXAMS AND CERTIFICATIONS
Loading...

Loading secure study guide viewer...

Page 0 of 0

Document Text

CODEHS ANIMATION AND

GAMES PRACTICE TEST

Question 1: Which CodeHS statement schedules the function animate to run

repeatedly every 50 milliseconds?

Choices:

1) setTimer(animate, 50); 2) setTimer(animate(), 50); 3) animateTimer(50, animate); 4) timer.call(animate);

Correct Answer: setTimer(animate, 50);

Explanation: CodeHS uses setTimer(callback, delay). Passing animate without parentheses registers it as the callback, and 50 is the delay in milliseconds.Page 1

Question 2: A program uses setTimer(update, 25). Ignoring normal browser timing

variation, how many times is update scheduled to run in one second?

Choices:

1) 25 times 2) 40 times 3) 50 times 4) 100 times

Correct Answer: 40 times

Explanation: One second is 1000 milliseconds. = 40, so the timer schedules about 40 callback executions per second.

Question 3: Why is the function name normally written without parentheses in

setTimer(moveBall, 40)?

Choices:

1) Because parentheses would make the delay become 0 2) Because setTimer needs the function itself as a callback rather than the result of calling it immediately 3) Because CodeHS functions cannot contain parentheses 4) Because moveBall is treated as a string Correct Answer: Because setTimer needs the function itself as a callback rather than the result of calling it immediately Explanation: setTimer expects a callback function. Writing moveBall passes the function itself; writing moveBall() calls it immediately and passes its return value instead.Page 2

Question 4: A circle has radius 15. Which expression chooses a random x-coordinate that keeps the entire circle on the canvas?

Choices:

1) Randomizer.nextInt(0, getWidth()) 2) Randomizer.nextInt(-15, getWidth() + 15) 3) Randomizer.nextInt(15, getWidth() - 15) 4) Randomizer.nextInt(0, getWidth() - 15)

Correct Answer: Randomizer.nextInt(15, getWidth() - 15)

Explanation: The circle center must stay at least one radius from each vertical edge, so x must be between 15 and getWidth() - 15.

Question 5: A timer was started with setTimer(moveEnemy, 30). Which statement

stops that timer?

Choices:

1) stopTimer(moveEnemy); 2) stopTimer; 3) clearTimer(moveEnemy); 4) setTimer(moveEnemy, 0);

Correct Answer: stopTimer(moveEnemy);

Explanation: CodeHS stops a timer by passing the same callback function to stopTimer.Therefore stopTimer(moveEnemy) stops the timer associated with moveEnemy.Page 3

Download Study Guide

Buy This Guide

$39.00 One-time purchase
Buy Now
  • Full access to this guide
  • Download anytime
  • No expiration

Study Guide Information

Category: EXAMS AND CERTIFICATIONS
Description:

CODEHS ANIMATION AND GAMES PRACTICE TEST Question 1: Which CodeHS statement schedules the function animate to run repeatedly every 50 milliseconds? Choices: 1) setTimer(animate, 50); 2) setTimer(an...

Get this guide $39.00