Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Answers


This section contains the answers to the lesson review questions in this chapter.


Lesson 1



  1. Correct answer: C
    A. Incorrect: The getContext method requires the 2d parameter, and there is no rectangle
    method on the context object.
    B. Incorrect: To draw on the canvas, you need to execute the getContext method to get a
    reference to a context object, and there is no rectangle method on the canvas object.
    C. Correct: This is the correct code, in which a reference to a context object is obtained by
    calling the getContext method with the 2d parameter.
    D. Incorrect: The getContext method requires the 2d parameter.

  2. Correct answer: B
    A. Incorrect: The arcTo method typically draws a line and an arc. Although it could accom-
    plish the task, it would be very difficult in comparison to the arc method.
    B. Correct: Using the arc method is the easiest way to accomplish this task.
    C. Incorrect: The circle method does not exist.
    D. Incorrect: The dot method does not exist.


Lesson 2



  1. Correct answer: D
    A. Incorrect: HTML is derived from SGML, but the element is XML-based.
    B. Incorrect: HTML is used for webpages, but the element is XML-based.
    C. Incorrect: XHTML is used for webpages, but the element is XML-based.
    D. Correct: The element is XML-based.

  2. Correct answer: C
    A. Incorrect: The zoom attribute does not exist.
    B. Incorrect: The window attribute does not exist.
    C. Correct: The viewBox attribute provides a window into the drawing and enables zoom
    capabilities.
    D. Incorrect: The zoomWindow attribute does not exist.

Free download pdf