Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Chapter: 38
Q701:
How can you change the source of an image with the ID banner using jQuery?
A. $('#banner img').attr('src', 'images/newimage.png');
B. $('#banner img').setSrc('images/newimage.png');
C. $('#banner img').src('images/newimage.png');
D. $('#banner img').updateSrc('images/newimage.png');
Correct Answer:
A
Chapter: 38
Q702:
Which jQuery method is used to remove an attribute from an element?
A. .removeAttr()
B. .removeProperty()
C. .deleteAttr()
D. .clearAttr()
Correct Answer:
A
Chapter: 38
Q703:
What does the mouseover event in jQuery do?
A. It triggers when the mouse pointer moves over an element
B. It triggers when the mouse pointer clicks on an element
C. It triggers when an element receives focus
D. It triggers when the mouse pointer leaves an element
Correct Answer:
A
Chapter: 39
Q704:
What does evt.preventDefault() do in jQuery event handling?
A. It stops the default behavior of the event, like form submission or link navigation
B. It sets a default value for the event
C. It logs the event details to the console
D. It stops the event from bubbling up the DOM tree
Correct Answer:
A
Chapter: 39
Q705:
How can you bind multiple events to an element using jQuery?
A. $('#selector').bind('click mouseover', function() {});
B. $('#selector').on('click mouseover', function() {});
C. $('#selector').click(function() {}).mouseover(function() {});
D. $('#selector').events('click mouseover', function() {});
Correct Answer:
B
Chapter: 39
Q706:
Which method is used to stop event bubbling in jQuery?
A. evt.stopPropagation()
B. evt.preventDefault()
C. evt.stopImmediatePropagation()
D. evt.cancelBubble()
Correct Answer:
A
Chapter: 39
Q707:
What is the purpose of $(document).ready() in jQuery?
A. It ensures that the DOM is fully loaded before executing the code
B. It binds events to elements as soon as they are created
C. It prevents the document from reloading
D. It executes the code immediately, bypassing DOM readiness
Correct Answer:
A
Chapter: 39
Q708:
How can you create a toggle effect for an element using jQuery?
A. $('#element').toggle()
B. $('#element').fadeToggle()
C. $('#element').slideToggle()
D. $('#element').showToggle()
Correct Answer:
A
Chapter: 39
Q709:
What is the effect of the slideDown() method in jQuery?
A. It makes an element slide down into view
B. It makes an element slide up out of view
C. It hides an element with a sliding effect
D. It toggles the visibility of an element with a sliding effect
Correct Answer:
A
Chapter: 39
Q710:
How can you animate multiple CSS properties at once in jQuery?
A. $('#element').animate({left: '100px', opacity: 0.5}, 1000);
B. $('#element').css({left: '100px', opacity: 0.5});
C. $('#element').transition({left: '100px', opacity: 0.5}, 1000);
D. $('#element').set({left: '100px', opacity: 0.5}, 1000);
Correct Answer:
A
Chapter: 39
Q711:
What is the purpose of the delay() method in jQuery animations?
A. It adds a delay before the next animation effect
B. It pauses the current animation effect
C. It sets a delay for the entire animation sequence
D. It stops the animation sequence after the delay
Correct Answer:
A
Chapter: 39
Q712:
Which method would you use to hide an element with a sliding effect in jQuery?
A. $('#element').slideUp()
B. $('#element').fadeOut()
C. $('#element').hide()
D. $('#element').slideDown()
Correct Answer:
A
Chapter: 39
Q713:
How can you prevent a link's default behavior using jQuery?
A. $(this).preventDefault();
B. evt.preventDefault();
C. $(this).stopImmediatePropagation();
D. $(this).stopPropagation();
Correct Answer:
B
Chapter: 39
Q714:
What does the animate() method in jQuery allow you to do?
A. Animate CSS properties over time
B. Change the CSS properties instantly
C. Add CSS properties to the element
D. Remove CSS properties from the element
Correct Answer:
A
Chapter: 39
Q715:
How would you append new content to an element using jQuery?
A. $('#element').append('<p>New content</p>');
B. $('#element').prepend('<p>New content</p>');
C. $('#element').replaceWith('<p>New content</p>');
D. $('#element').before('<p>New content</p>');
Correct Answer:
A
Chapter: 39
Q716:
Which event handler should be used to execute code when a form is submitted?
A. $('#form').submit(function() {});
B. $('#form').click(function() {});
C. $('#form').change(function() {});
D. $('#form').focus(function() {});
Correct Answer:
A
Chapter: 39
Q717:
How can you show an element with a fade-in effect in jQuery?
A. $('#element').fadeIn();
B. $('#element').slideDown();
C. $('#element').show();
D. $('#element').slideUp();
Correct Answer:
A
Chapter: 39
Q718:
How can you bind an event to multiple elements using jQuery?
A. $('selector').bind('click', function() {});
B. $('#selector').on('click', function() {});
C. $('.selector').click(function() {});
D. $('.selector').bind('click', function() {});
Correct Answer:
B
Chapter: 40
Q719:
What does AJAX allow you to do on a web page?
A. Load new HTML content without reloading the page
B. Create static pages with no server interaction
C. Change the browser's default behavior
D. Perform operations on the server without a connection
Correct Answer:
A
Chapter: 40
Q720:
Which object is used in JavaScript to make AJAX requests?
A. XMLHttpRequest
B. AjaxRequest
C. HttpRequest
D. AsyncRequest
Correct Answer:
A