web tech banner

Web Technology Multiple Choice Questions (MCQs) and Answers

Master Web Technology with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Web Technology concepts. Begin your placement preparation journey now!

Q31

Q31 A CSS file is linked but styles are not applied. What could be a possible cause?

A

Missing rel="stylesheet"

B

Incorrect path in href

C

CSS syntax error

D

HTML is not valid

Q32

Q32 Why might a CSS grid layout not work as expected?

A

Missing display: grid

B

Incorrect grid-template syntax

C

Unsupported browser

D

Improper media queries

Q33

Q33 What is JavaScript primarily used for in web development?

A

Styling web pages

B

Creating dynamic web content

C

Managing databases

D

Designing UI

Q34

Q34 Which of the following is a valid JavaScript data type?

A

Integer

B

Character

C

Boolean

D

Float

Q35

Q35 What is the correct syntax to write a comment in JavaScript?

A

// This is a comment

B

<!-- This is a comment -->

C

# This is a comment

D

/* This is a comment */

Q36

Q36 Which keyword is used to declare a variable in JavaScript?

A

let

B

define

C

create

D

var

Q37

Q37 What does the typeof operator do in JavaScript?

A

Determines the type of a variable

B

Changes the data type

C

Declares a variable

D

Checks nullability

Q38

Q38 How do you write a function in JavaScript?

A

function myFunc() {}

B

def myFunc() {}

C

func myFunc() {}

D

method myFunc() {}

Q39

Q39 What is the correct way to display a message in the browser console?

A

alert("Hello")

B

console.log("Hello")

C

document.write("Hello")

D

print("Hello")

Q40

Q40 How do you call a function named myFunction in JavaScript?

A

call myFunction()

B

myFunction()

C

execute myFunction()

D

invoke myFunction()

Q41

Q41 Why might a JavaScript function not run when the page loads?

A

Function is not defined

B

Syntax error

C

Function call is missing

D

All of the above

Q42

Q42 Why might console.log(variableName) throw an error in JavaScript?

A

Variable is not defined

B

Incorrect syntax

C

Reserved keyword used as variable name

D

All of the above

Q43

Q43 Why does the following code throw an error: const a; a = 5;?

A

Missing semicolon

B

const variables must be initialized

C

Incorrect syntax

D

Variable redeclaration

Q44

Q44 What does DOM stand for in web development?

A

Document Object Model

B

Data Object Mapping

C

Dynamic Object Management

D

Document Outline Mapping

Q45

Q45 Which JavaScript method is used to access an element by its ID in the DOM?

A

getElementById()

B

querySelector()

C

getElementsByClassName()

D

getIdElement()

Q46

Q46 What is the role of document in DOM manipulation?

A

To define event listeners

B

To provide access to the entire HTML document

C

To store styles

D

To declare variables

Q47

Q47 What is the difference between innerHTML and textContent in DOM manipulation?

A

innerHTML sets text and HTML elements

B

textContent is faster

C

Both

D

Neither

Q48

Q48 Which code snippet changes the text of a paragraph with the ID "demo"?

A

document.querySelector("demo").text = "Hello";

B

document.getElementById("demo").innerHTML = "Hello";

C

document.getById("demo").html = "Hello";

D

document.get("demo").value = "Hello";

Q49

Q49 How do you add a new list item to an unordered list with the ID "myList"?

A

appendChild("li");

B

document.getElementById("myList").appendChild(liElement);

C

addChild("myList", "li");

D

document.get("myList").addChild("li");

Q50

Q50 Which JavaScript method is used to remove a specific element from the DOM?

A

deleteElement()

B

removeChild()

C

removeElement()

D

destroyElement()

Q51

Q51 How can you dynamically create a new <div> element in the DOM?

A

createElement('div')

B

document.createElement('div')

C

new Div()

D

create('div')

Q52

Q52 Why might a DOM manipulation script fail to execute?

A

Syntax errors in the script

B

Script is placed before DOM loads

C

Invalid element selectors

D

Missing event listeners

Q53

Q53 A dynamically added button does not respond to a click event. What could be the reason?

A

Incorrect event listener type

B

Event listener added before element creation

C

Syntax error in handler

D

Improper callback function

Q54

Q54 Why might document.querySelector(".myClass").innerHTML return null?

A

Element does not exist

B

Class name is misspelled

C

JavaScript executes before DOM loads

D

Element is dynamically generated later

Q55

Q55 What is the primary goal of responsive web design?

A

To create interactive content

B

To make web pages adapt to different screen sizes

C

To enhance web security

D

To improve website loading speed

Q56

Q56 Which of the following is used in responsive design to make layouts flexible?

A

Grid systems

B

CSS media queries

C

Both

D

None of the above

Q57

Q57 What does the viewport meta tag in HTML control?

A

Page content width

B

Browser zoom level

C

Device orientation

D

Text alignment

Q58

Q58 Which of the following is a common CSS unit for responsive design?

A

px

B

cm

C

vh

D

in

Q59

Q59 How do CSS media queries enhance responsive design?

A

By dynamically loading images

B

By defining breakpoints for styling

C

By optimizing performance

D

By adjusting text readability

Q60

Q60 Which CSS media query will apply styles to devices with a maximum width of 600px?

A

@media (min-width: 600px)

B

@media (max-width: 600px)

C

@media (width: 600px)

D

@media (device-width: 600px)

ad verticalad vertical
ad