Font size
WorksheetsLesson 9: Creating Animations, Working with Graphics, and Access
Total questions: 20
Worksheet time: 10mins
1. ______ is a key part of animation.
Parsing
Recursion
Encapsulation
AppCache
Which of the following do developers commonly use in JavaScript to create timings in animations?
getElementById
XMLHttpRequest
setTimeout
createElement
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();
}
You can’t use getElementById in an animation.
You can’t use the absolute value in an animation.
A semicolon is missing after function init().
A curly bracket is missing after function init().
You are creating an application in which you want to display a PNG file using JavaScript. Which method should you use?
getContext
XMLHttpRequest
setTimeout
createElement
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>
respond to a button click
display logo.png
display logo-sml.jpg
result in an error every time
Which of the following is a dynamic graphical element? (Choose all that apply.)
JPG
canvas
PNG
SVG
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.)
createElement
move_paragraph
getElementById
canvas.getContext
Which of the following statements is true? (Choose all that apply.)
You can animate a canvas drawing.
You can animate an SVG drawing.
The getElementById method creates a reusable function to display an image.
A scanned photograph is considered a dynamic format.
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);
}
getElementById
XMLHttpRequest
setTimeout
createElement
What is encapsulation?
a programming technique in which a function calls itself
grouping data and the methods that operate on it under a single name
analysis of complex information into constituent parts
assigning data types to parsed data
What is parsing?
a programming technique in which a function calls itself
grouping data and the methods that operate on it under a single name
analysis of complex information into constituent parts
assigning data types to parsed data
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);
});
creates a call to the server
specifies the HTTP method for contacting the server and provides the server’s Web address
creates the JavaScript object
uses JSON parse to get a response from the server
Which of the following statements is true of AppCache?
Web server must be configured with the correct MIME type, which is text/cache-manifest
saves a copy of your local files to a Web server
uses browser cache to specify the files a Web browser should cache offline
AppCache and browser cache are the same
Which of the following is an example of a data type?
1234
Boolean
seven
ABCD
_____ 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.
Browser cache
JPGs
Manifest files
Cookies
What is an alternative to cookies?
local storage
parsing
recursion
AppCache
To send and receive data explicitly in JavaScript requires which of the following? (Choose all that apply.)
server-side programming
WebSockets
CSS
a dynamic Web server
Which of the following can expose data and is therefore not considered as secure as alternatives?
the Local Storage feature
cookies
AppCache
recursion
Which API is most closely related to parsing?
XMLHttpRequest
AppCache
File
JSON.stringify
. What is the following code most likely associated with?
var id = setInterval(function() {
/* show current frame */
if (/* finished */) clearInterval(id) }, 8)
encapsulation
animation
parsing
data storage
