Sample Questions and Answers
Which of the following HTML elements is used to create a hyperlink?
A) <a>
B) <button>
C) <form>
D) <link>
Answer: A
Which of the following JavaScript methods is used to convert a JSON string into a JavaScript object?
A) JSON.parse()
B) JSON.stringify()
C) JSON.convert()
D) JSON.parseObject()
Answer: A
Which of the following defines an object in JavaScript?
A) {key: value, key: value}
B) key = value;
C) var key = value;
D) key => value;
Answer: A
Which of the following is used to modify the structure of a webpage dynamically using JavaScript?
A) Document Object Model (DOM)
B) Cascading Style Sheets (CSS)
C) Hypertext Preprocessor (PHP)
D) Hypertext Markup Language (HTML)
Answer: A
Which of the following is true about the use of sessionStorage in JavaScript?
A) Data stored in sessionStorage persists across browser tabs and windows
B) Data stored in sessionStorage persists only for the duration of the page session
C) Data in sessionStorage is automatically deleted after 24 hours
D) sessionStorage can store encrypted data only
Answer: B
Which of the following describes the purpose of the meta tag in HTML?
A) It is used to define the visual style of an element
B) It provides metadata such as the character set, author, or viewport settings
C) It is used to add hyperlinks to other websites
D) It defines a JavaScript function for form validation
Answer: B
Which of the following is used to create an unordered list in HTML?
A) <ul>
B) <ol>
C) <dl>
D) <list>
Answer: A
Which of the following is true about the getElementById() method in JavaScript?
A) It selects the first element with the specified class name
B) It selects the first element with the specified tag name
C) It selects the element with the specified ID attribute
D) It selects the last element with the specified class name
Answer: C
Which of the following is the primary purpose of a cookie in web development?
A) To store encrypted user credentials for security
B) To store user-specific data for a session, such as preferences or login status
C) To load images asynchronously on a webpage
D) To control the visibility of HTML elements
Answer: B
Which of the following is the correct CSS property used to set the background color of an element?
A) background-color
B) color-background
C) bgcolor
D) background-style
Answer: A
Which of the following best describes the fetch API in JavaScript?
A) It retrieves data from the server synchronously
B) It is used to create new data on the server
C) It is used to make asynchronous requests to the server and handle the response
D) It fetches files from the local file system
Answer: C
Which of the following is the purpose of the flex property in CSS?
A) It allows items within a flex container to grow and shrink based on available space
B) It sets the width of items in a flex container
C) It defines the layout for the flex container
D) It defines the direction of a flex container
Answer: A
Which of the following is a valid HTML5 input type used for selecting a date?
A) <input type=”date”>
B) <input type=”calendar”>
C) <input type=”datetime”>
D) <input type=”text” type=”date”>
Answer: A
Which of the following is an example of a server-side programming language?
A) JavaScript
B) HTML
C) PHP
D) CSS
Answer: C
Which of the following is a feature of the grid layout in CSS?
A) It allows for two-dimensional layout of elements in both rows and columns
B) It is used to position items in a single row only
C) It is used to control text alignment within elements
D) It is used to arrange elements in a circular pattern
Answer: A
Which of the following HTML elements is used to define a form in a webpage?
A) <form>
B) <input>
C) <button>
D) <fieldset>
Answer: A
Which of the following methods is used to parse a JSON string in JavaScript?
A) JSON.parse()
B) JSON.stringify()
C) JSON.decode()
D) JSON.parseString()
Answer: A
Which of the following is used to display a message in the browser’s console for debugging purposes in JavaScript?
A) console.log()
B) alert()
C) document.write()
D) log.message()
Answer: A
Which of the following describes a “progressive web app” (PWA)?
A) A mobile application that uses a native framework for development
B) A website that can function offline and be installed on a user’s device
C) A website with fixed content that doesn’t change
D) A mobile app that works only on iOS devices
Answer: B
Which of the following is a feature of CSS transitions?
A) They allow elements to move from one state to another with an animation
B) They allow elements to appear and disappear instantaneously
C) They are used to create loops of animations
D) They are only supported by certain browsers
Answer: A
Which of the following is used to store large amounts of data in a key-value format in a web browser?
A) LocalStorage
B) Cookies
C) IndexedDB
D) SessionStorage
Answer: C
Which of the following CSS properties is used to center an element horizontally within its parent container?
A) margin: 0 auto;
B) text-align: center;
C) display: flex; justify-content: center;
D) position: absolute; left: 50%;
Answer: A
Which of the following describes the DOM (Document Object Model) in web development?
A) It is used to define the layout and style of a webpage
B) It is a programming interface for HTML and XML documents, representing the page as a tree structure
C) It is a method of handling the server-client interaction
D) It is used to retrieve JSON data from an API
Answer: B
Which of the following is a method of preventing SQL injection attacks in web development?
A) Use inline SQL queries in JavaScript
B) Always use prepared statements with bound parameters
C) Use eval() to execute user input
D) Disable all user input fields
Answer: B
Which of the following JavaScript methods is used to return the first element that matches a given CSS selector?
A) querySelector()
B) getElementById()
C) getElementsByClassName()
D) querySelectorAll()
Answer: A
Which of the following describes the z-index property in CSS?
A) It determines the vertical alignment of elements
B) It controls the stacking order of elements on the z-axis (overlapping elements)
C) It controls the transparency of elements
D) It defines the maximum width of an element
Answer: B
Which of the following is a best practice for optimizing the performance of a website?
A) Using large images without compression
B) Minimizing the use of JavaScript
C) Compressing images and minifying CSS and JavaScript files
D) Avoiding the use of a CDN
Answer: C
Which of the following JavaScript functions is used to extract a section of an array?
A) slice()
B) splice()
C) split()
D) filter()
Answer: A
Which of the following is a method of authenticating users in a web application?
A) Using cookies to store passwords
B) Using OAuth or JWT (JSON Web Tokens) for token-based authentication
C) Storing user credentials in plain text
D) Storing session data in localStorage
Answer: B
Reviews
There are no reviews yet.