JavaScript Questions & Answers – Drag and Drop Events

«
»

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Drag and Drop Events”.

1. DOM Level 3 Events standardizes which of the following events?
a) focusarea and focusover
b) focusall and focusnone
c) focusdown and focusup
d) focusin and focusout
View Answer

Answer: d
Explanation: The DOM Level 3 Events specification standardizes the focusin and focusout events as bubbling alternatives to the focus and blur events. The focusin and focusout events bubble, the focus and blur events doesn’t. That means that you can use the focusin and focusout on the parent element of a form field.
advertisement

2. Which of the following are the necessary events currently?
a) DOMActivate
b) DOMFocusIn
c) DOMNodeInserted
d) Onclick
View Answer

Answer: d
Explanation: Browsers are still allowed to generate events like DOMActivate, DOMFocusIn, and DOMNodeInserted, but these are no longer required. For example DOM activate occurs when any element becomes activate.

3. Which object is passed as the argument to handlers for keydown, keyup, and keypress events?
a) KeyboardEvent
b) Key Event
c) Mouse Event
d) Alphabet Event
View Answer

Answer: a
Explanation: What is new in the DOM Level 3 Events specification is standardized support for two dimensional mouse wheels via the wheel event and better support for text input events with a new KeyboardEvent object that is passed as the argument to handlers for keydown, keyup, and keypress events.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement

4. Which among these is a property that reports rotation of mouse wheel axes?
a) ctrlKey
b) alterX
c) alterY
d) deltaX
View Answer

Answer: d
Explanation: A handler for a wheel event receives an event object with all the usual mouse event properties, and also deltaX, deltaY, and deltaZ properties that report rotation around three different mouse wheel axes.

5. Which of the following property specifies the string of text that was entered?
a) message
b) data
c) string
d) text
View Answer

Answer: b
Explanation: A textinput event handler has a data property that specifies the string of text that was entered. This data property is used for manipulating the data which is entered by the user.
advertisement

6. Which of the following is defined by the specification?
a) dataMethod
b) input
c) inputMethod
d) inputdataMethod
View Answer

Answer: c
Explanation: The specification defines an inputMethod property on the event object and a set of constants representing different kinds of text input (keyboard, paste or drop, handwriting or voice recognition, and so on). prompt function is a kind of input method.

7. Which two events will have the generated text for key events?
a) key and char
b) char and text
c) text and key
d) key and value
View Answer

Answer: a
Explanation: For key events that generate printable characters, key and char will be equal to the generated text. Both key and char are onkeypress event which occurs when the user presses a key (on the keyboard).
advertisement

8. Which of the following are the drag and drop events?
a) drop
b) dragstart
c) both drop and dragstart
d) dropover
View Answer

Answer: c
Explanation: HTML Drag and Drop interfaces enable applications to use drag and drop features in Firefox and other browsers. The API defines the following seven event types :

  1. dragstart
  2. drag
  3. dragend
  4. dragenter
  5. dragover
  6. dragleave
  7. drop

9. Which property holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available?
a) dataTransfer
b) transferData
c) dataExchange
d) exchangeData
View Answer

Answer: a
Explanation: The property, dataTransfer, holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available. The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation.
advertisement

10. Which API allows scripts in a document from one server to exchange messages with scripts?
a) Cross-Document Messaging API
b) Web application API
c) Both Cross-Document Messaging API & Web application API
d) Cross-linking API
View Answer

Answer: a
Explanation: The Cross-Document Messaging API allows scripts in a document from one server to exchange messages with scripts in a document from another server. This works around the limitations of the same-origin policy in a secure way. Each message that is sent triggers a message event on the Window of the receiving document.

Sanfoundry Global Education & Learning Series – Javascript Programming.

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 & technical discussions at Telegram SanfoundryClasses.