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!

Q91

Q91 What is the correct syntax to write a basic HTTP server in Node.js?

A

require('server').start();

B

http.createServer().listen(3000);

C

node.createServer('3000');

D

server.listen('3000');

Q92

Q92 In PHP, how do you connect to a MySQL database using mysqli?

A

mysqli_connect('localhost', 'user', 'password', 'database');

B

connect_db('localhost', 'user', 'password', 'database');

C

php_connect('localhost', 'user', 'password', 'database');

D

db_connect('localhost', 'user', 'password', 'database');

Q93

Q93 How do you define a route in an Express.js application?

A

app.get('/', (req, res) => { res.send('Hello'); });

B

route('/', 'GET', 'Hello');

C

express('/', 'GET', 'Hello');

D

app.route('/', 'Hello');

Q94

Q94 Why might a server fail to start in Node.js?

A

Missing modules

B

Incorrect port configuration

C

Syntax error

D

Invalid environment variables

Q95

Q95 Why might a PHP script not connect to a MySQL database?

A

Incorrect database credentials

B

MySQL server not running

C

Missing mysqli extension

D

All of the above

Q96

Q96 A POST request to an Express.js route does not work. What could be the reason?

A

Missing middleware

B

Route method mismatch

C

Invalid data format

D

Improperly configured headers

Q97

Q97 What is the primary purpose of web hosting?

A

To manage DNS settings

B

To provide servers for storing website files

C

To configure databases

D

To design web pages

Q98

Q98 Which of the following is a shared hosting characteristic?

A

Dedicated server for one user

B

Limited resources shared among multiple users

C

Exclusive IP address

D

High cost

Q99

Q99 What is a CDN in the context of web hosting?

A

Content Delivery Network

B

Cloud Data Network

C

Compressed Data Network

D

Central Data Node

Q100

Q100 Which of the following hosting types is most suitable for large-scale applications?

A

Shared hosting

B

VPS hosting

C

Dedicated hosting

D

Free hosting

Q101

Q101 How does cloud hosting differ from traditional hosting?

A

It is cheaper

B

It uses multiple servers instead of one

C

It is only for small websites

D

It doesn't require a database

Q102

Q102 Which of the following is the correct command to deploy an application to Heroku?

A

heroku upload app

B

heroku deploy app

C

git push heroku main

D

heroku deploy main

Q103

Q103 How do you configure an Nginx server to host a static website?

A

Use proxy_pass for the HTML files

B

Set root to the directory containing the static files

C

Set listen to 443

D

Set server_name to localhost

Q104

Q104 What is the correct syntax to configure a custom domain for a deployed Firebase project?

A

firebase deploy domain example.com

B

firebase set domain example.com

C

firebase hosting:domain add example.com

D

firebase domain add example.com

Q105

Q105 Why might a deployed website not load in the browser?

A

DNS settings not configured

B

Server is offline

C

Incorrect file permissions

D

Application crash on deployment

Q106

Q106 Why might a static website hosted on GitHub Pages not display properly?

A

Missing index.html file

B

Incorrect branch settings

C

Repository is private

D

Unresolved relative paths

Q107

Q107 What is the purpose of HTTPS in web security?

A

To speed up website loading

B

To encrypt data transmission

C

To prevent server downtime

D

To block advertisements

Q108

Q108 What is Cross-Site Scripting (XSS)?

A

Injecting malicious scripts into websites

B

Breaking server encryption

C

Exploiting server downtime

D

Attacking DNS records

Q109

Q109 Which security measure can mitigate SQL injection attacks?

A

Input validation

B

Using secure cookies

C

Implementing HTTPS

D

Disabling caching

Q110

Q110 What is the primary purpose of a Content Security Policy (CSP)?

A

To block cookies

B

To prevent unauthorized scripts

C

To optimize page performance

D

To manage server downtime

Q111

Q111 What is a CSRF (Cross-Site Request Forgery) attack?

A

A brute-force attack on passwords

B

An unauthorized action performed on behalf of an authenticated user

C

A type of DoS attack

D

A method to steal cookies

Q112

Q112 How do you implement HTTPS on a web server using Nginx?

A

Add an ssl_certificate and ssl_certificate_key in the server block

B

Enable proxy_pass

C

Set listen to 80

D

Disable server_name

Q113

Q113 How do you set HTTP security headers using Node.js?

A

response.setHeader('X-Content-Type-Options', 'nosniff');

B

response.addHeader('X-Content-Type', 'nosniff');

C

response.header('Content-Security-Policy', 'nosniff');

D

response.securityHeader('X-Content-Type', 'nosniff');

Q114

Q114 Why might a website show a "Mixed Content" warning in the browser?

A

Using both HTTP and HTTPS resources

B

Incorrect server configuration

C

Missing CSS files

D

Invalid HTML syntax

Q115

Q115 Why might a web application fail to block an XSS attack?

A

Improper input validation

B

No Content Security Policy (CSP)

C

Lack of secure encoding

D

Insufficient testing

Q116

Q116 What does HTTP stand for?

A

HyperText Transfer Protocol

B

HyperText Transmission Process

C

High-Tech Transfer Protocol

D

Hyperlink Transmission Protocol

Q117

Q117 Which HTTP method is used to retrieve data from a server?

A

GET

B

POST

C

PUT

D

DELETE

Q118

Q118 What is the purpose of the HTTP HEAD method?

A

To retrieve data

B

To send data

C

To fetch headers only

D

To delete resources

Q119

Q119 What does a 404 HTTP status code indicate?

A

Successful request

B

Client error

C

Server error

D

Redirection

Q120

Q120 What is the purpose of the HTTP OPTIONS method?

A

To request supported HTTP methods

B

To upload files

C

To redirect a request

D

To fetch cookies

ad verticalad vertical
ad