Fundamentals of Front End Development MCQs with Answers
Practice important Fundamentals of Front End Development MCQs with answers and explanations.
Chapter: 141
Q1581:
Which method is used to get the user's current position in HTML Geolocation?
A. getCurrentPosition()
B. getPosition()
C. getUserLocation()
D. getCurrentLocation()
Correct Answer:
A
Chapter: 141
Q1582:
What is required for the Geolocation API to provide the user's position?
A. User's IP address
B. User's consent
C. User's browser type
D. User's device type
Correct Answer:
B
Chapter: 141
Q1583:
What property returns the latitude as a decimal number?
A. coords.longitude
B. coords.latitude
C. coords.accuracy
D. coords.altitude
Correct Answer:
B
Chapter: 141
Q1584:
How can you handle errors in the getCurrentPosition() method?
A. Use a try-catch block
B. Use a promise
C. Pass a second function parameter
D. Use an error object
Correct Answer:
C
Chapter: 141
Q1585:
Which of the following is NOT a property returned by the getCurrentPosition() method?
A. coords.altitude
B. coords.heading
C. coords.speed
D. coords.address
Correct Answer:
D
Chapter: 141
Q1586:
Fill in the blank: To display location on a map, you need access to a ______ that can use latitude and longitude.
A. map service
B. GPS device
C. browser plugin
D. location service
Correct Answer:
A
Chapter: 141
Q1587:
Fill in the blank: The ______ property provides the accuracy of the position returned by the Geolocation API.
A. coords.latitude
B. coords.accuracy
C. coords.altitude
D. coords.heading
Correct Answer:
B
Chapter: 141
Q1588:
What method is used to stop continuous location updates from watchPosition()?
A. clearPosition()
B. stopWatch()
C. clearWatch()
D. endWatch()
Correct Answer:
C
Chapter: 141
Q1589:
Fill in the blank: The 'getCurrentPosition()' method returns an object containing latitude, longitude, and ______.
A. altitude
B. address
C. heading
D. city
Correct Answer:
A
Chapter: 141
Q1590:
What should the second parameter of getCurrentPosition() method specify?
A. A function to handle errors
B. A function to show position
C. A callback to refresh the position
D. A function to stop the process
Correct Answer:
A
Chapter: 142
Q1591:
How do you make an element draggable in HTML5?
A. Set draggable="false"
B. Set draggable="true"
C. Add class "draggable"
D. Use JavaScript only
Correct Answer:
B
Chapter: 142
Q1592:
Which attribute specifies the data type and value of the dragged data?
A. ondragstart
B. dataTransfer.setData()
C. ondrop
D. draggable
Correct Answer:
B
Chapter: 142
Q1593:
What method must be called to allow a drop in HTML5 drag and drop?
A. event.preventDefault()
B. event.stopPropagation()
C. event.setData()
D. event.allowDrop()
Correct Answer:
A
Chapter: 142
Q1594:
What does the ondragover event specify?
A. Where the dragged data can be dropped
B. The type of data being dragged
C. The ID of the draggable element
D. The data to be set for dragging
Correct Answer:
A
Chapter: 142
Q1595:
What happens if you do not call event.preventDefault() in the ondragover event?
A. Dragged data can be dropped
B. Dragged data cannot be dropped
C. Dragging is disabled
D. The draggable element is deleted
Correct Answer:
B
Chapter: 142
Q1596:
Fill in the blank: The function ______ is called during the ondragstart event to specify what data should be dragged.
A. setData()
B. drag()
C. drop()
D. appendChild()
Correct Answer:
B
Chapter: 142
Q1597:
Fill in the blank: The method ______ retrieves the data that was set during the ondragstart event.
A. dataTransfer.getData()
B. event.preventDefault()
C. dataTransfer.setData()
D. event.stopPropagation()
Correct Answer:
A
Chapter: 142
Q1598:
Which method is used to append the dragged element to the drop target?
A. appendChild()
B. createElement()
C. insertBefore()
D. removeChild()
Correct Answer:
A
Chapter: 142
Q1599:
Fill in the blank: To handle the drop event, you need to call the ______ method to prevent default behavior.
A. dataTransfer.setData()
B. event.preventDefault()
C. dataTransfer.getData()
D. draggable.setAttribute()
Correct Answer:
B
Chapter: 142
Q1600:
What must be done to allow an element to be dropped into a target element?
A. Set target's draggable attribute to true
B. Call event.preventDefault() in ondragover
C. Set the drop target's data type
D. Add an ondrop event to the target element
Correct Answer:
B