


















































































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 HTML element is used to define the main content of a document that is directly related to or expands upon the central topic? A) B) C) D) Answer: B Explanation: represents the dominant content of the and should be unique to the page, improving accessibility and SEO. Question 2. In HTML5, which attribute on the tag specifies the character encoding for the document? A) `name` B) `http-equiv` C) `charset` D) `content` Answer: C Explanation: The `charset` attribute declares the character encoding (e.g., UTF‑8) and must be placed inside the. Question 3. Which of the following is a block‑level element by default? A) B) C) D) Answer: C
Explanation: creates a block container that starts on a new line and stretches to the full width of its parent. **Question 4.** When creating a form, which attribute determines how form data is sent to the server? A) `action` B) `method` C) `enctype` D) `autocomplete` Answer: B Explanation: The `method` attribute specifies the HTTP verb (`GET` or `POST`) used to submit the form. **Question 5.** Which input type provides a slider control for numeric values? A) `range` B) `number` C) `tel` D) `date` Answer: A Explanation: renders a draggable slider allowing selection of a numeric value within a defined range. Question 6. To associate a with an for better accessibility, which two attributes must correspond? A) class and id B) for and id
Question 9. Which attribute on the element opens the linked document in a new browser tab? A) `target="_blank"` B) `rel="noopener"` C) `href="_new"` D) `download` Answer: A Explanation: `target="_blank"` instructs the browser to open the link in a new tab or window. **Question 10.** Which ARIA role should be added to a that functions as a button? A) role="navigation" B) role="button" C) role="banner" D) role="dialog" Answer: B Explanation: role="button" informs assistive technologies that the `` behaves like a button. Question 11. In CSS, which selector matches any element that has a data-state attribute equal to "open"? A) [data-state="open"] B) .data-state="open" C) *data-state=open D) #data-state(open) Answer: A
Explanation: Attribute selectors use square brackets; [attr="value"] selects elements with that exact attribute/value. Question 12. What is the specificity value of a selector consisting of an ID selector and a class selector (e.g., #nav .item)? A) 0,1, B) 1,0, C) 1,1, D) 0,2, Answer: B Explanation: Specificity is calculated as (inline, IDs, classes/attributes/pseudo‑classes, elements/pseudo‑elements). #nav gives 1 ID, .item gives 1 class → 1,0,1. Question 13. Which CSS property controls the space between the element’s border and its content? A) margin B) border C) padding D) outline Answer: C Explanation: padding adds inner spacing between the content and the border. Question 14. When box-sizing: border-box; is applied to an element, how is the element’s total width calculated? A) width = content + padding + border B) width = content only
B) flex-direction C) align-content D) gap Answer: B Explanation: flex-direction sets the main axis to row, row-reverse, column, or column- reverse. Question 18. In CSS Grid, what does the value grid-template-columns: repeat(3, 1fr); create? A) Three columns each 1 pixel wide B) Three equal‑width columns that share the available space C) Three columns with fixed widths of 1 rem D) A single column repeated three times Answer: B Explanation: repeat(3, 1fr) generates three columns, each taking an equal fraction (1fr) of the remaining space. Question 19. Which property places a grid item to start at the second column line and end at the fourth column line? A) grid-column: 2 / 4; B) grid-area: 2 / 4; C) grid-row: 2 / 4; D) grid-column-start: 2; grid-column-end: 4; Answer: A Explanation: grid-column: start / end; defines the column lines the item spans.
Question 20. What does the CSS media query @media (max-width: 600px) target? A) Devices wider than 600 px B) Devices exactly 600 px wide C) Devices narrower than or equal to 600 px D) Devices with height less than 600 px Answer: C Explanation: max-width applies the styles when the viewport width is ≤ 600 px, enabling mobile‑first adjustments. Question 21. Which CSS property creates a smooth transition when a button’s background color changes on hover? A) animation B) transition C) transform D) filter Answer: B Explanation: transition defines the properties, duration, and easing for a gradual change between states. Question 22. Which of the following is a correct syntax for defining a CSS custom property (variable) named --primary-color? A) --primary-color: #0066ff; B) $primary-color: #0066ff; C) var(--primary-color) = #0066ff; D) @primary-color: #0066ff; Answer: A
!=Answer: C Explanation: === checks both value and type, avoiding implicit conversion. Question 26. What is the output of the following code?
let x = 0; for (let i = 0; i < 5; i++) { x += i; } console.log(x); A) 10 B) 15 C) 5 D) 0 Answer: A Explanation: The loop adds 0+1+2+3+4 = 10 to x. Question 27. Which method creates a new array containing the results of applying a function to each element of the original array? A) filter() B) map() C) reduce() D) forEach()
Answer: B Explanation: map() returns a new array with the transformed values. Question 28. In ES6, what does the spread operator (...) do when used inside an array literal? A) Joins two arrays into a string B) Expands an iterable into individual elements C) Creates a shallow copy of an object D) Performs a deep clone of an array Answer: B Explanation: The spread operator iterates over an iterable (e.g., array) and inserts each element into the surrounding array. Question 29. Which of the following statements about JavaScript arrow functions is true? A) They have their own this binding. B) They can be used as constructors with new. C) They cannot contain a return statement. D) They inherit this from the lexical scope. Answer: D Explanation: Arrow functions do not create their own this; they capture the surrounding lexical this. Question 30. How do you create a promise that resolves after 2 seconds with the value "done"? A) new Promise(resolve => setTimeout(resolve("done"), 2000)); B) new Promise((resolve) => setTimeout(() => resolve("done"), 2000));
A) appendChild() B) insertBefore() C) replaceChild() D) removeChild() Answer: A Explanation: appendChild() appends the specified node as the last child of the parent. Question 34. How can you add a CSS class named active to an element stored in variable btn? A) btn.className = "active"; B) btn.classList.add("active"); C) btn.setAttribute("class", "active"); D) btn.style.class = "active"; Answer: B Explanation: classList.add() safely adds a class without overwriting existing classes. Question 35. Which event type is fired when a form is submitted? A) click B) submit C) change D) input Answer: B Explanation: The submit event occurs on the `` element when the user attempts to submit it.
Question 36. In event propagation, which phase occurs first? A) Bubbling B) Capturing C) Target D) Delegation Answer: B Explanation: During capturing, the event travels from the document root down to the target element before bubbling. Question 37. Which method of the Fetch API returns a Promise that resolves to a Response object? A) fetch() B) axios() C) XMLHttpRequest() D) request() Answer: A Explanation: fetch(url) initiates a network request and returns a Promise resolving to a Response. Question 38. When handling a JSON response from fetch, which method should be called on the Response object? A) .text() B) .json() C) .blob() D) .arrayBuffer() Answer: B
C) Updates the package.json file D) Removes all node_modules Answer: B Explanation: Without arguments, npm reads package.json and installs the required packages into node_modules. Question 42. In a package.json file, which field specifies the command that runs the development server? A) main B) scripts.start C) dependencies D) engines Answer: B Explanation: The scripts object contains custom commands; npm start runs the script defined at scripts.start. Question 43. Which of the following tools is primarily used to bundle JavaScript modules for the browser? A) Babel B) ESLint C) Webpack D) Prettier Answer: C Explanation: Webpack analyzes dependencies and bundles them into one or more files for efficient delivery.
Question 44. In browser DevTools, which panel shows network requests and their timing information? A) Elements B) Console C) Network D) Sources Answer: C Explanation: The Network panel lists each HTTP request, status, size, and timing details. Question 45. Which JavaScript error occurs when trying to call a method on undefined? A) ReferenceError B) SyntaxError C) TypeError D) RangeError Answer: C Explanation: TypeError is thrown when a value is not of the expected type, such as invoking a method on undefined. Question 46. In performance optimization, which technique reduces the number of HTTP requests for images? A) Minifying CSS B) Using a CDN C) Sprite sheets or CSS image sprites D) Enabling gzip compression Answer: C Explanation: Image sprites combine multiple images into a single file, decreasing request count.
Explanation: useState returns a state variable and a setter function, enabling stateful logic in functional components. Question 50. What does the term “virtual DOM” refer to in modern JavaScript frameworks? A) A server‑side rendering technique B) A lightweight JavaScript representation of the actual DOM used for efficient updates C) A CSS preprocessor D) A browser extension for debugging Answer: B Explanation: The virtual DOM is an in‑memory tree that allows frameworks to compute minimal changes before updating the real DOM. Question 51. Which HTML element is appropriate for marking up a self‑contained piece of content that could be syndicated, such as a blog post? A) B) C) D) Answer: B Explanation: represents an independent, reusable piece of content. **Question 52.** Which tag instructs browsers to set the viewport width to the device width and initial scale to 1? A) B)
C) D) Answer: A Explanation: This viewport meta tag is essential for responsive design on mobile devices. Question 53. Which HTML attribute makes a form field mandatory for submission? A) required B) readonly C) disabled D) autofocus Answer: A Explanation: The required attribute forces the browser to validate that the field has a value before submitting. Question 54. In CSS, which pseudo‑class selects the first child of its parent? A) :first-of-type B) :first-child C) ::first-line D) :nth-child(1) Answer: B Explanation: :first-child matches an element that is the first child of its parent. Question 55. Which of the following CSS selectors matches any `` element whose type attribute starts with “date”? A) input[type^="date"]