HTML CSS JS REACT intermediate test 4
HTML CSS JS REACT intermediate test 4
only)
4:30 to 6:30 pm
Tech Round by Feeroz sir and Shazia Mam
Instructions:
Choose the correct answer for each question.
Each question carries one mark.
No negative marking.
Section 1: HTML (6 Questions)
1. Which of the following attributes is used to specify a character
encoding for an HTML document?
A) charset
B) encoding
C) content
D) type
2. What is the purpose of the <template> tag in HTML5?
A) To define a reusable block of HTML that is not rendered
when the page loads
B) To create a form template
C) To define a layout structure
D) To include external templates
3. How can you specify that an input field should accept only
numeric values?
A) <input type="number">
B) <input type="text" pattern="\d+">
C) Both A and B
D) <input type="numeric">
4. What is the difference between <div> and <span> elements
in HTML?
A) <div> is inline, while <span> is block-level
B) <div> is block-level, while <span> is inline
C) Both are block-level elements
D) Both are inline elements
5. Which HTML element is used to define a section in a document
that can be styled with CSS?
A) <section>
B) <style>
C) <div>
D) Both A and C
6. What does the sandbox attribute do when added to
an <iframe> element?
A) It allows all scripts to run within the iframe
B) It restricts actions within the iframe for security
purposes
C) It allows cross-origin requests
D) It enables full screen mode
Section 2: CSS (6 Questions)
7. Which property is used to create space between an element's
border and its content?
A) margin
B) padding
C) border-spacing
D) spacing
8. What does the CSS calc() function do?
A) It calculates the sum of two numbers only.
B) It allows you to perform calculations to set CSS
property values.
C) It calculates the height of an element.
D) None of the above.
9. How can you create a CSS grid layout with three equal
columns?
A) display: grid; grid-template-columns: 1fr 1fr 1fr;
B) display: flex; flex-direction: row;
C) display: inline-block; width: 33.33%;
D) All of the above.
10. What does the !important rule in CSS do?
A) It makes a style rule more specific.
B) It overrides any other style rules for that property.
C) It applies styles only when certain conditions are met.
D) It marks a style as deprecated.
11. Which of the following CSS properties can be animated
using CSS transitions?
A) background-color
B) display
C) position
D) float
12. How do you apply styles conditionally based on screen
size using CSS?
A) Media queries
B) Conditional statements in CSS
C) Using JavaScript only
D) By using different stylesheets for different devices
Section 3: Bootstrap (6 Questions)
13. What class would you use to create a responsive table in
Bootstrap?
A) .table-responsive
B) .table-fluid
C) .table-fixed
D) .responsive-table
14. In Bootstrap, how do you align text to the center within a
column?
A) .text-center
B) .align-center
C) .justify-content-center
D) .text-middle
15. Which Bootstrap component would you use to create a
tabbed interface?
A) Accordion
B ) Carousel
– C ) Navs
– D ) Alerts
16. How can you customize Bootstrap's default variables?
– A ) By editing Bootstrap's source files directly
– B ) By using Sass variables
– C ) By overriding styles in your custom stylesheet
– D ) All of the above
17. What class would you use to create a modal dialog in
Bootstrap?
– A ) .modal-dialog
– B ) .modal-content
– C ) .modal
– D ) All of the above
18. How do you implement responsive images in Bootstrap
5?
– A ) Use .img-responsive class only
– B ) Use .img-fluid class only
– C ) Use both classes together
– D ) Use .responsive-img class only
Section 4: JavaScript (6 Questions)
19. What will be the output of console.log([] + []) in
JavaScript?
A) []
B) ""
C) undefined
D) TypeError
20. Which method can be used to convert an array into a
string in JavaScript?
– A ) join()
– B ) concat()
– C ) split()
– D ) push()
21. In JavaScript, what does closure mean?
– A ) The ability of a function to remember its lexical scope
even when it is executed outside that scope
– B ) The process of closing an application
– C ) The ability to encapsulate data within an object
– D ) None of these
22. Which operator is used to check both value and type in
JavaScript?
– A ) ==
– B ) ===
– C ) !==
– D ) =!
23. What will be logged to the console if you
run console.log(typeof NaN) in JavaScript?
– A ) "number"
– B ) "NaN"
– C ) "undefined"
– D ) "object"
24. Which function can be used to execute asynchronous
code after a delay in JavaScript?
– A ) setTimeout()
– B ) requestAnimationFrame()
– C ) setInterval()
– D ) asyncFunction()
Section 5: React (6 Questions)
25. What lifecycle method is called immediately after a
component is mounted in React class components?
– A ) componentDidMount()
– B ) componentWillMount()
– C ) render()
– D ) componentDidUpdate()
26. In React, what is the purpose of keys in lists?
– A ) To uniquely identify elements for efficient updates and
rendering
– B ) To store additional data related to each element
– C ) To manage state across components
– D ) To define styles for list items
27. How do you prevent default form submission behavior in
React?
– A ) By using event.preventDefault() inside onSubmit handler
– B ) By returning false from onSubmit handler
– C ) By setting action="" on form element
– D ) None of these
28. Which hook would you use to manage complex state logic
in React components?
– A ) useState()
– B ) useEffect()
– C ) useReducer()
– D ) useContext()
29. How can context be utilized in React applications?
– A ) For prop drilling
— B ) For global state management without passing props
down manually
— C ) For rendering lists efficiently
— D ) None of these
30. In React, what does Suspense allow you to do?
— A ) Handle errors during rendering
— B ) Load components lazily while showing fallback content
— C ) Manage state across multiple components
— D ) Optimize performance by memoizing components
------------------------------------------------------------------------------------------------
--------------
2. Debounce Function:
1. Write a debounce function that limits the rate
at which a function can fire. For example, if a
user types in a search box, you want to wait
until they stop typing for a certain amount of
time before making an API call.
2. Example: debounce(func, wait) should return a
new function that delays invoking func until
after wait milliseconds have elapsed since the
last time it was invoked.
3. Find the largest and second largest in an array
[1, 3, 5, -5, 1]; ans : 5 and 3