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!

Q121

Q121 Which HTTP header is used to specify the media type of the resource?

A

Content-Type

B

Accept

C

Authorization

D

Cache-Control

Q122

Q122 How do you set a custom HTTP status code in an Express.js response?

A

response.setStatus(404);

B

response.status(404).send('Not Found');

C

response.httpCode(404);

D

response.error(404);

Q123

Q123 Why might a browser display a "400 Bad Request" error?

A

Malformed URL

B

Large request payload

C

Invalid syntax in the request

D

Unsupported protocol

Q124

Q124 Why might an HTTP response return a "500 Internal Server Error"?

A

Server-side script error

B

Database connection failure

C

Misconfigured server

D

Exceeded memory limit

Q125

Q125 What does REST stand for?

A

Representational State Transfer

B

Remote Entity Service Transmission

C

Resource Entity Service Type

D

Resource State Transfer

Q126

Q126 Which HTTP method is typically used to update a resource in a RESTful API?

A

GET

B

POST

C

PUT

D

DELETE

Q127

Q127 What is a key characteristic of RESTful web services?

A

Stateful communication

B

Server-side sessions

C

Stateless communication

D

Requires SOAP

Q128

Q128 Which of the following is a standard HTTP response code for a successful DELETE request?

A

200

B

201

C

204

D

400

Q129

Q129 Why are URI endpoints crucial in RESTful APIs?

A

They define methods

B

They identify resources

C

They store server data

D

They ensure authentication

Q130

Q130 How do you make a GET request to a RESTful API using Fetch API?

A

fetch('url', { method: 'GET' });

B

fetch('url');

C

fetch.get('url');

D

GET.fetch('url');

Q131

Q131 How do you parse JSON data returned from a RESTful API in JavaScript?

A

response.data();

B

response.toJSON();

C

response.json();

D

response.parseJSON();

Q132

Q132 How do you send custom headers in a RESTful API request using Axios?

A

axios.get('url', headers: { Authorization: 'token' });

B

axios.get('url', { headers: { Authorization: 'token' } });

C

axios.get('url', { header: 'Authorization: token' });

D

axios.headers('url', Authorization: 'token');

Q133

Q133 Why might a RESTful API request return a 401 Unauthorized error?

A

Invalid credentials

B

Missing authentication token

C

Token is expired

D

Invalid URL

Q134

Q134 Why might a RESTful API return a CORS (Cross-Origin Resource Sharing) error?

A

API URL is invalid

B

Server not configured for CORS

C

Browser is outdated

D

HTTP method is unsupported

Q135

Q135 What is the primary purpose of cookies in web development?

A

To store session data on the server

B

To store small amounts of data in the browser

C

To increase website speed

D

To prevent XSS attacks

Q136

Q136 What is the main difference between cookies and local storage?

A

Cookies have larger storage limits

B

Cookies are sent with each HTTP request

C

Local storage is server-side

D

Local storage expires automatically

Q137

Q137 Which attribute of a cookie ensures it is only sent over HTTPS?

A

Secure

B

HttpOnly

C

Domain

D

Path

Q138

Q138 What is the purpose of the HttpOnly attribute in cookies?

A

It encrypts cookies

B

It prevents client-side scripts from accessing cookies

C

It extends cookie lifespan

D

It sets the domain of the cookie

Q139

Q139 How do you set a cookie in JavaScript?

A

document.setCookie("user=John");

B

document.cookie = "user=John";

C

set.cookie("user=John");

D

cookie.document("user=John");

Q140

Q140 How do you store data in local storage using JavaScript?

A

localStorage.setItem('key', 'value');

B

localStorage.addItem('key', 'value');

C

localStorage.store('key', 'value');

D

localStorage.saveItem('key', 'value');

Q141

Q141 Why might a cookie fail to store on the client?

A

Cookie exceeds size limit

B

Domain mismatch

C

Incorrect attributes

D

Secure attribute not set

Q142

Q142 Why might local storage fail to retrieve data?

A

Incorrect key name

B

Browser does not support local storage

C

Storage was cleared

D

Access denied by browser settings

Q143

Q143 What is the primary purpose of web performance optimization?

A

To increase server capacity

B

To reduce page load times

C

To improve SEO

D

To minimize JavaScript code

Q144

Q144 Which technique can reduce the size of JavaScript files for faster loading?

A

Minification

B

Normalization

C

Caching

D

Compression

Q145

Q145 How does lazy loading improve performance?

A

It compresses assets

B

It loads images and resources only when needed

C

It prioritizes large files

D

It minimizes CSS usage

Q146

Q146 What is the purpose of a Content Delivery Network (CDN) in optimization?

A

To host databases

B

To distribute content across multiple servers

C

To compress web pages

D

To minimize DOM size

Q147

Q147 Which HTML attribute can be used to defer the loading of JavaScript files?

A

async

B

defer

C

lazy

D

postload

Q148

Q148 How do you enable Gzip compression on an Nginx server?

A

gzip on;

B

enable gzip;

C

nginx gzip enable;

D

compress gzip on;

Q149

Q149 Why might a website have poor performance despite using a CDN?

A

CDN is misconfigured

B

Assets are not optimized

C

Too many HTTP requests

D

Insufficient bandwidth

Q150

Q150 Why might browser caching not work as expected?

A

Incorrect cache-control headers

B

Cache expiration time not set

C

Dynamic content not cacheable

D

User disabled browser cache

ad verticalad vertical
ad