































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































































Question 1. Which protocol is primarily used to securely transmit data over the web? A) HTTP B) FTP C) HTTPS D) SMTP Answer: C Explanation: HTTPS (HyperText Transfer Protocol Secure) encrypts data between the client and server, ensuring secure communication over the web, unlike HTTP which transmits data in plain text. Question 2. In client-server architecture, what is the main role of the client? A) Store data B) Request resources and services C) Host web content D) Manage server hardware Answer: B Explanation: The client initiates requests to the server to retrieve or send data, acting as the user interface for web interactions. Question 3. Which of the following is NOT a semantic HTML5 element? A) B) C) D) Answer: B Explanation: is a generic container without semantic meaning, whereas elements like , , and provide meaningful structure. Question 4. What does the element in HTML define? A) External stylesheets B) Metadata about the document
C) Inline scripts D) Hyperlinks Answer: B Explanation: tags provide metadata such as character set, author, viewport settings, and other information about the document. Question 5. Which attribute is used with tags to open the link in a new tab? A) target="_self" B) target="_blank" C) target="_parent" D) target="_top" Answer: B Explanation: target="_blank" opens the linked document in a new browser tab or window. Question 6. How can images be made responsive using HTML5? A) Using fixed width and height attributes only B) Using srcset and elements C) Using only CSS D) By setting alt attribute only Answer: B Explanation: srcset and allow serving different images based on device resolution or viewport size, making images responsive. Question 7. Which HTML element is used to define a table header cell? A) B) C) D) Answer: B
B) relative C) absolute D) fixed Answer: D Explanation: position: fixed; positions the element relative to the viewport, remaining in place during scrolling. Question 12. Which CSS layout module is best suited for creating complex grid-based designs? A) Flexbox B) Grid C) Float D) Positioning Answer: B Explanation: CSS Grid provides a two-dimensional layout system ideal for complex, grid-based designs. Question 13. Which media query condition targets devices with a maximum width of 768px? A) @media (min-width: 768px) B) @media (max-width: 768px) C) @media (orientation: landscape) D) @media (resolution: 300dpi) Answer: B Explanation: max-width: 768px applies styles when the viewport width is less than or equal to 768 pixels. Question 14. Which CSS property is used to create smooth transitions between property changes? A) animation B) transition C) keyframes D) transform
Answer: B Explanation: transition property enables smooth changes of CSS properties over a specified duration. Question 15. How are custom CSS properties, also known as variables, defined? A) --variable-name: value; B) @variable name { } C) var(--variable-name); D) #variable { } Answer: A Explanation: Custom properties are defined with a double hyphen prefix, e.g., --main-color: #333;. Question 16. Which JavaScript keyword is used to declare a block-scoped variable? A) var B) let C) const D) both B and C Answer: D Explanation: Both let and const declare block-scoped variables; var is function-scoped. Question 17. Which operator is used for strict equality comparison in JavaScript? A) == B) = C) === D) != Answer: C Explanation: === compares both value and type, providing a strict equality check. Question 18. What does the 'switch' statement in JavaScript do? A) Executes code based on multiple conditions
Explanation: fetch() initiates HTTP requests to retrieve resources asynchronously. Question 22. What does the 'Promise' object in JavaScript represent? A) Synchronous operation B) An asynchronous operation that will complete in the future C) An error handler D) A DOM element Answer: B Explanation: Promise encapsulates an eventual result or error from an asynchronous operation. Question 23. How do you handle errors in a Promise chain? A) Using .try() B) Using .catch() C) Using .error() D) Using .fail() Answer: B Explanation: .catch() registers a callback for handling rejected promises or errors. Question 24. Which Web API method is used to send HTTP GET requests? A) XMLHttpRequest.open() B) fetch() C) send() D) request() Answer: B Explanation: fetch() can be used to send GET requests easily and handles promises for asynchronous operations. Question 25. How can local storage data be persisted across browser sessions? A) Using sessionStorage
B) Using localStorage C) Using cookies only D) Using server-side storage Answer: B Explanation: localStorage persists data even after the browser is closed, unlike sessionStorage which lasts only for the session. Question 26. Which API provides the current geographic location of the user? A) Geolocation API B) Navigator API C) Location API D) GPS API Answer: A Explanation: The Geolocation API allows web pages to access the device's geographic position, with user permission. Question 27. Which JavaScript method schedules a function to run repeatedly at specified intervals? A) setTimeout() B) setInterval() C) setRepeat() D) repeat() Answer: B Explanation: setInterval() executes a function repeatedly at specified time intervals. Question 28. Which command initializes a new local Git repository? A) git start B) git init C) git clone D) git create
Question 32. Which attribute in an HTML form element specifies the URL where form data is sent? A) method B) action C) enctype D) target Answer: B Explanation: The action attribute specifies the URL of the server-side script that processes the form data. Question 33. Which CSS property is used to control the space between lines of text? A) line-height B) letter-spacing C) word-spacing D) text-indent Answer: A Explanation: line-height adjusts the spacing between lines within text blocks. Question 34. Which CSS property is used to set the transparency level of an element? A) opacity B) visibility C) transparency D) alpha Answer: A Explanation: opacity controls the transparency of an element, with 0 being fully transparent and 1 fully opaque. Question 35. Which JavaScript method is used to remove an element from the DOM? A) delete() B) remove() C) detach()
D) erase() Answer: B Explanation: element.remove() removes the element from the DOM tree. Question 36. What does the DOM stand for? A) Document Object Model B) Document Object Management C) Data Object Model D) Document Open Model Answer: A Explanation: The DOM is a programming interface that represents the structure of an HTML or XML document as a tree of objects. Question 37. Which event is fired when a user submits a form? A) change B) submit C) load D) click Answer: B Explanation: The submit event occurs when a form is submitted, either by clicking a submit button or pressing Enter. Question 38. Which JavaScript feature allows writing asynchronous code more readably? A) Callbacks B) Promises C) Async/await D) Event listeners Answer: C Explanation: async/await syntax provides a more straightforward way to write asynchronous code that looks synchronous.
D) flex-grow Answer: C Explanation: The order property specifies the order in which flex items appear within a flex container. Question 43. Which JavaScript method converts a JSON string into an object? A) JSON.stringify() B) JSON.parse() C) JSON.convert() D) JSON.objectify() Answer: B Explanation: JSON.parse() parses a JSON string and returns the corresponding JavaScript object. Question 44. Which HTML element is used for defining a caption for a table? A) B) C) <header> D) <legend> Answer: A Explanation: <caption> provides a title or description for a table. Question 45. Which CSS property is used to set the background image of an element? A) background-color B) background-image C) background D) image-url Answer: B Explanation: background-image sets one or more background images for an element. Question 46. Which JavaScript method is used to add a new element as a child of an existing element?
A) createElement() B) appendChild() C) insertBefore() D) addChild() Answer: B Explanation: appendChild() adds a new node as the last child of a specified parent node. Question 47. Which HTML attribute associates a label with an input element? A) for B) id C) label D) name Answer: A Explanation: The for attribute links a label to an input element by matching the input's id attribute. Question 48. Which of the following is a pseudo-class in CSS? A) ::before B) :hover C) .class D) #id Answer: B Explanation: :hover targets elements when the user hovers over them. Question 49. Which property is used in CSS to make a layout sticky? A) position: fixed B) position: absolute C) position: sticky D) position: relative Answer: C
Question 53. How do you select all elements with the class 'active' using CSS? A) .active B) #active C) *active D) active Answer: A Explanation: .active targets all elements with the class attribute 'active'. Question 54. Which JavaScript method can be used to retrieve all elements with a specific class? A) getElementByClassName() B) getElementsByClassName() C) querySelector() D) querySelectorAll() Answer: B Explanation: getElementsByClassName() returns a live HTMLCollection of all elements with the specified class. Question 55. Which HTML element is used to group related options in a form? A) B) C) D) Answer: A Explanation: groups related form controls, often with a border and optional legend. Question 56. How is a CSS media query typically written? A) @media (max-width: 768px) { ... } B) media (max-width: 768px) { ... } C) @query (max-width: 768px) { ... }
D) @responsive { ... } Answer: A Explanation: @media specifies styles that apply under certain media conditions, such as screen width. Question 57. Which method is used to add a new element to the DOM? A) createElement() B) appendChild() C) insertBefore() D) All of the above Answer: D Explanation: createElement() creates a new element; appendChild() and insertBefore() add it into the DOM. Question 58. Which HTTP status code indicates a successful GET request? A) 200 B) 404 C) 500 D) 301 Answer: A Explanation: 200 OK indicates the request was successful and the server returned the requested data. Question 59. Which HTML element is used to define a list item? A) B) C) D) Answer: B Explanation: defines an item within ordered () or unordered () lists.
C) D) Answer: A Explanation: defines a footer for the nearest sectioning content or the entire page. Question 64. Which CSS property is used to make an element transparent? A) transparency B) opacity C) visibility D) filter Answer: B Explanation: opacity controls transparency; 0 is fully transparent, 1 is fully opaque. Question 65. How can JavaScript access an element with the ID 'header'? A) document.querySelector('#header') B) document.getElementById('header') C) document.getElementsByName('header') D) Both A and B Answer: D Explanation: Both document.querySelector('#header') and document.getElementById('header') select the element with id 'header'. Question 66. Which HTML element is used to embed a video? A) B) C) D) Answer: B Explanation: embeds video content with optional controls and sources.
Question 67. Which CSS property is used to align items vertically in Flexbox? A) justify-content B) align-items C) align-self D) flex-direction Answer: B Explanation: align-items aligns flex items vertically (cross-axis) within the flex container. Question 68. Which JavaScript method is used to fetch data asynchronously and automatically parse JSON? A) fetch().then(res => res.json()) B) fetch().parse() C) getJSON() D) load() Answer: A Explanation: fetch() returns a promise; calling res.json() parses the JSON response. Question 69. Which HTML element is used to define a section of a document that contains navigational links? A) B) C) D) Answer: A Explanation: defines a section containing navigation links. Question 70. Which CSS property is used to specify the size of an element's border's corner radii? A) border-radius