JavaScript Questions & Answers – Animation

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Animation”.

1. Which of the following can be implemented using animation?
a) Fireworks
b) Fade Effect
c) Roll-in or Roll-out
d) All of the mentioned
View Answer

Answer: d
Explanation: JavaScript animations are done by programming gradual changes in an element’s style. You can use JavaScript to create a complex animation which includes but not limited to:

  • Fireworks
  • Fade Effect
  • Roll-in or Roll-out
  • Page-in or Page-out
  • Object movements.

2. Which is the function that calls another function after a time interval?
a) setTimeout()
b) setTime()
c) callafter()
d) timeSet()
View Answer

Answer: a
Explanation: The setTimeout(function, duration) calls function after duration milliseconds from now. setInterval(function, milliseconds) is same as setTimeout(), but repeats the execution of the function continuously.

3. Which function is used to clear the timer value?
a) clearTimervalue()
b) clearTimeout()
c) clear()
d) flush(timer)
View Answer

Answer: b
Explanation: The clearTimeout() method clears a timer set with the setTimeout() method. The ID value returned by setTimeout() is used as the parameter for the clearTimeout() method.
advertisement
advertisement

4. Which is the property used to position the object in the left of the screen?
a) object.position = left
b) object = position.left
c) object.style.left
d) object.shiftleft
View Answer

Answer: c
Explanation: The property object.style.left = distance in pixels or points sets distance from left edge of the screen. This property specifies the left position of the element including padding, scrollbar, border and margin. Whereas the setTimeout(function, duration) calls function after duration milliseconds from now.

5. Which is the function used to call a function in every time duration?
a) callafter()
b) setInterval()
c) setTimeout()
d) setTime()
View Answer

Answer: b
Explanation: The setInterval(function, duration) calls function after every duration milliseconds.

6. How do we get the DOM object in JavaScript?
a) getElementbyId()
b) getObject()
c) getElement()
d) getNodeobject()
View Answer

Answer: a
Explanation: The getElementbyId() is used to get the DOM object in JavaScript by simply calling that function associated with the HTML document. The object in this method gets referenced by the id name.

7. How to assign the image source in JavaScript?
a) image = “url”
b) source(“url”)
c) image.src = “url”
d) img.src=”url”
View Answer

Answer: c
Explanation: For accesing any image in webpage its address or url is specified. The image source is defined as image.src = “/images/html.gif”.
advertisement

8. How do we create and preload an image object in JavaScript?
a) Use new keyword
b) Call Image()
c) Both Use new keyword and Call Image()
d) Set image()
View Answer

Answer: c
Explanation: The Image() constructor creates and preloads a new image object. The url is specified and the image is preloaded.

9. Which event handler is triggered when the user’s mouse moves onto a link?
a) onMouseOver
b) onMouseOut
c) onMouse
d) onMouseOnto
View Answer

Answer: a
Explanation: The onmouseover attribute fires when the mouse pointer moves over an element. The onmouseover attribute is often used together with the onmouseout attribute.
advertisement

10. Which event handler is triggered when the user’s mouse moves away from a link?
a) onMouseOver
b) onMouseOut
c) onMouse
d) onMouseOnto
View Answer

Answer: b
Explanation: The onMouseOut event handler is triggered when the user’s mouse moves away from the link. It is often used together with onMouseOver attribute.

Sanfoundry Global Education & Learning Series – Javascript Programming.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.