Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q721: How do you initiate a GET request using XMLHttpRequest?
- A: xhr.open('GET', 'url'); xhr.send();
- B: xhr.request('GET', 'url'); xhr.execute();
- C: xhr.sendRequest('GET', 'url');
- D: xhr.fetch('GET', 'url'); xhr.send();
View Answer
A
Q722: How can you handle a response status of 404 in AJAX?
- A: Check xhr.status === 404 and handle the error
- B: Automatically retry the request
- C: Display a generic error message without checking status
- D: Continue with default response without any action
View Answer
A
Q723: What is the purpose of $.get() in jQuery?
- A: To send a GET request to the server and process the response
- B: To send a POST request to the server and process the response
- C: To create a new HTML element and append it to the page
- D: To serialize form data and send it to the server
View Answer
A
Q724: How do you load HTML content into a specific element using jQuery?
- A: $('#element').load('url');
- B: $('#element').fetch('url');
- C: $('#element').append('url');
- D: $('#element').insert('url');
View Answer
A
Q725: What does $.post() do in jQuery?
- A: Sends a POST request to the server with data and processes the response
- B: Fetches a JSON object from the server
- C: Loads an HTML snippet into a specified element
- D: Creates a new server connection and sends data
View Answer
A
Q726: Which method is used to encode a query string in jQuery?
- A: encodeURIComponent()
- B: encodeURI()
- C: encodeQuery()
- D: encodeString()
View Answer
A
Q727: What is the purpose of $.getJSON() in jQuery?
- A: To send a GET request for JSON data and automatically parse it
- B: To send a GET request and handle plain text responses
- C: To send a POST request and handle form submissions
- D: To send a request and receive XML responses
View Answer
A
Q728: How do you handle errors in AJAX requests with jQuery?
- A: Use .fail() or .error() methods to handle errors
- B: Use .done() to handle errors
- C: Use .complete() to handle errors
- D: Errors are handled automatically without any need for explicit handling
View Answer
A
Q729: How can you prevent a default link behavior in jQuery?
- A: Use event.preventDefault()
- B: Use event.stopPropagation()
- C: Use event.stopImmediatePropagation()
- D: Use event.cancelBubble()
View Answer
A
Q730: What does $(document).ready() ensure?
- A: Executes the code only after the DOM is fully loaded
- B: Executes the code immediately before the DOM is loaded
- C: Binds events as soon as the page starts loading
- D: Ensures the page is not reloaded before executing the code
View Answer
A