Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Chapter: 40
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();
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
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');
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
Q726:
Which method is used to encode a query string in jQuery?
A. encodeURIComponent()
B. encodeURI()
C. encodeQuery()
D. encodeString()
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
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()
Correct Answer:
A
Chapter: 40
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
Correct Answer:
A
Chapter: 40
Q731:
How do you process a response from an AJAX request?
A. Use a callback function to handle the response data
B. Use response.data() to access the data
C. Use response.text() to process the response
D. Use response.parse() to handle the response
Correct Answer:
A
Chapter: 40
Q732:
How can you serialize form data in jQuery?
A. Use the .serialize() method on the form element
B. Use the .stringify() method on the form element
C. Use the .encode() method on the form element
D. Use the .format() method on the form element
Correct Answer:
A
Chapter: 40
Q733:
What does $.each() do with JSON data?
A. Iterates over JSON data to process each item
B. Encodes JSON data into a string
C. Decodes JSON data into an object
D. Fetches JSON data from the server
Correct Answer:
A
Chapter: 41
Q734:
What is the syntax to create a new instance of NSMutableArray in Objective-C?
A. NSMutableArray *array = [NSMutableArray alloc];
B. NSMutableArray *array = [[NSMutableArray alloc] init];
C. NSMutableArray *array = [NSMutableArray init];
D. NSMutableArray *array = [[NSMutableArray alloc] create];
Correct Answer:
B
Chapter: 41
Q735:
How do you initialize an NSMutableArray object after allocation in Objective-C?
A. [array init]
B. [array initialize]
C. [[array alloc] init]
D. [[array init] alloc]
Correct Answer:
C
Chapter: 41
Q736:
What is the method to add an object to an NSMutableArray in Objective-C?
A. [array appendObject:object]
B. [array addObject:object]
C. [array insertObject:object]
D. [array pushObject:object]
Correct Answer:
B
Chapter: 41
Q737:
How can you replace objects in a specific range of an NSMutableArray?
A. [array replaceObjectsInRange:range withObjectsFromArray:anotherArray range:anotherRange]
B. [array replaceObjectsInRange:anotherArray withObjectsFromArray:range]
C. [array swapObjectsInRange:range withObjects:anotherArray]
D. [array updateObjectsInRange:range with:anotherArray]
Correct Answer:
A
Chapter: 41
Q738:
How do you release an NSMutableArray object and avoid dangling pointers?
A. [array release]; array = nil;
B. [array free]; array = null;
C. [array dispose]; array = nullptr;
D. [array clear]; array = empty;
Correct Answer:
A
Chapter: 41
Q739:
What does the @ symbol signify when used with strings in Objective-C?
A. Creates an NSString object directly
B. Represents a pointer to a char array
C. Indicates a literal NSString object
D. Marks a string for memory management
Correct Answer:
C
Chapter: 41
Q740:
What is the correct way to declare a class method in Objective-C?
A. + (id)methodName;
B. - (id)methodName;
C. + (void)methodName;
D. - (void)methodName;
Correct Answer:
A