wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lesson 9: Creating Animations, Working with Graphics, and Access

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

1. ______ is a key part of animation.

a)

Parsing

b)

Recursion

c)

Encapsulation

d)

AppCache

2.

Which of the following do developers commonly use in JavaScript to create timings in animations?

a)

getElementById

b)

XMLHttpRequest

c)

setTimeout

d)

createElement

3.

What is the error in the following code that’s part of an animation program?

function init()

paragraph = document.getElementById("original");

paragraph.style.position = "absolute";

current = 0;

move_paragraph();

}

a)

You can’t use getElementById in an animation.

b)

You can’t use the absolute value in an animation.

c)

A semicolon is missing after function init().

d)

A curly bracket is missing after function init().

4.

You are creating an application in which you want to display a PNG file using JavaScript. Which method should you use?

a)

getContext

b)

XMLHttpRequest

c)

setTimeout

d)

createElement

5.

You are creating an application in which you want to display a PNG file using JavaScript. What would the following code do in your program?

<button onclick="show_image

(images/logo-sml.png', 276,110, 'Logo');">

Display logo</button>

a)

respond to a button click

b)

display logo.png

c)

display logo-sml.jpg

d)

result in an error every time

6.

Which of the following is a dynamic graphical element? (Choose all that apply.)

a)

JPG

b)

canvas

c)

PNG

d)

SVG

7.

You are writing a script to create a canvas graphic. Which of the following constructs are you most likely to use? (Choose all that apply.)

a)

createElement

b)

move_paragraph

c)

getElementById

d)

canvas.getContext

8.

Which of the following statements is true? (Choose all that apply.)

a)

You can animate a canvas drawing.

b)

You can animate an SVG drawing.

c)

The getElementById method creates a reusable function to display an image.

d)

A scanned photograph is considered a dynamic format.

9.

You are developing a JavaScript program that transfers data between a client and a server. What would you substitute for the word OBJECT in the following code?

function load(url, data, callback) {

var xhr = new OBJECT();

xhr.open("GET", url, true);

xhr.onload = function() {

callback(xhr.responseText);

}

xhr.send(data);

}

a)

getElementById

b)

XMLHttpRequest

c)

setTimeout

d)

createElement

10.

What is encapsulation?

a)

a programming technique in which a function calls itself

b)

grouping data and the methods that operate on it under a single name

c)

analysis of complex information into constituent parts

d)

assigning data types to parsed data

11.

What is parsing?

a)

a programming technique in which a function calls itself

b)

grouping data and the methods that operate on it under a single name

c)

analysis of complex information into constituent parts

d)

assigning data types to parsed data

12.

In the following code, what does the callback function accomplish?

function loadJSON(url, data, callback) {

var xhr = new XMLHttpRequest();

xhr.open("GET", url, true);

xhr.onload = function() {

callback( JSON.parse(xhr.responseText) );

}

xhr.send( JSON.stringify(data) );

}

loadJSON("my.json", { id : 1 }, function(response) {

setTitle(response.title);

});

a)

creates a call to the server

b)

specifies the HTTP method for contacting the server and provides the server’s Web address

c)

creates the JavaScript object

d)

uses JSON parse to get a response from the server

13.

Which of the following statements is true of AppCache?

a)

Web server must be configured with the correct MIME type, which is text/cache-manifest

b)

saves a copy of your local files to a Web server

c)

uses browser cache to specify the files a Web browser should cache offline

d)

AppCache and browser cache are the same

14.

Which of the following is an example of a data type?

a)

1234

b)

Boolean

c)

seven

d)

ABCD

15.

_____ is/are small text files that Web sites save to a computer’s hard disk that contain information about the user and his or her browsing preferences.

a)

Browser cache

b)

JPGs

c)

Manifest files

d)

Cookies

16.

What is an alternative to cookies?

a)

local storage

b)

parsing

c)

recursion

d)

AppCache

17.

To send and receive data explicitly in JavaScript requires which of the following? (Choose all that apply.)

a)

server-side programming

b)

WebSockets

c)

CSS

d)

a dynamic Web server

18.

Which of the following can expose data and is therefore not considered as secure as alternatives?

a)

the Local Storage feature

b)

cookies

c)

AppCache

d)

recursion

19.

Which API is most closely related to parsing?

a)

XMLHttpRequest

b)

AppCache

c)

File

d)

JSON.stringify

20.

. What is the following code most likely associated with?

var id = setInterval(function() {

/* show current frame */

if (/* finished */) clearInterval(id) }, 8)

a)

encapsulation

b)

animation

c)

parsing

d)

data storage