0% found this document useful (0 votes)
2 views14 pages

Sample Exam Questions

The document contains a set of 40 multiple-choice questions (MCQs) covering web technologies, including HTML, CSS, JavaScript, and general web protocols. Each section includes questions about specific tags, properties, and concepts related to web development. An answer key is provided for all questions, along with additional short and long answer questions related to web technology concepts.

Uploaded by

waynemoore55
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views14 pages

Sample Exam Questions

The document contains a set of 40 multiple-choice questions (MCQs) covering web technologies, including HTML, CSS, JavaScript, and general web protocols. Each section includes questions about specific tags, properties, and concepts related to web development. An answer key is provided for all questions, along with additional short and long answer questions related to web technology concepts.

Uploaded by

waynemoore55
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

10/7/25, 3:39 PM Sample exam questions

Web Technology – 40 MCQs

HTML (1–10)
1. Which tag is used to define an HTML document?
a) <body>
b) <html>
c) <head>
d) <title>
2. What does HTML stand for?
a) Hyperlinks and Text Markup Language
b) Home Tool Markup Language
c) Hyper Text Markup Language
d) Hyper Tool Markup Language
3. Which tag is used to insert an image in HTML?
a) <pic>
b) <image>
c) <img>
d) <src>
4. What attribute is used to provide an alternative text for an image?
a) alt
b) src
c) title
d) link

5. Which tag is used to create a checkbox in HTML?


a) <input type="radio">
b) <input type="box">
c) <input type="checkbox">
d) <input type="check">
6. What does the <br> tag do?
a) Inserts a horizontal line
b) Inserts a line break
c) Breaks the page
d) None of the above

[Link] 1/14
10/7/25, 3:39 PM Sample exam questions

7. Which element is used for the largest heading in HTML?


a) <heading>
b) <h6>
c) <h1>
d) <head>
8. Which tag is used to create a hyperlink?
a) <link>
b) <a>
c) <href>
d) <url>
9. The correct HTML tag for inserting a line horizontally is:
a) <line>
b) <hr>
c) <br>
d) <tr>

10. How can you create an ordered list in HTML?


a) <ul>
b) <ol>
c) <list>
d) <dl>

CSS (11–20)
11. What does CSS stand for?
a) Computer Style Sheets
b) Creative Style System
c) Cascading Style Sheets
d) Colorful Style Sheets

12. Which property is used to change the text color?


a) font-color
b) text-color
c) color
d) text-style

[Link] 2/14
10/7/25, 3:39 PM Sample exam questions

13. Which CSS property controls the text size?


a) font-style
b) text-size
c) font-size
d) text-style
14. How do you insert a comment in CSS?
a) // this is a comment
b) <!-- this is a comment -->
c) /* this is a comment */
d) # this is a comment
15. Which CSS property is used to set the background color?
a) color
b) bgcolor
c) background-color
d) background
16. How do you make a class in CSS?
a) #classname
b) .classname
c) classname
d) @classname
17. Which selector selects all <p> elements inside a <div> ?
a) div + p
b) div p
c) div > p
d) div.p

18. Which property is used to make text bold?


a) text-weight: bold;
b) font-weight: bold;
c) font-style: bold;
d) text-style: bold;

19. Which unit is relative to the font size of the element?


a) px
b) em

[Link] 3/14
10/7/25, 3:39 PM Sample exam questions

c) %
d) cm

20. Which is the correct syntax for an ID selector in CSS?


a) .idname
b) #idname
c) idname
d) *idname

JavaScript (21–30)
21. Which of the following is a JavaScript data type?
a) String
b) Number
c) Boolean
d) All of the above
22. What symbol is used for comments in JavaScript?
a) <!-- comment -->
b) // comment
c) ## comment
d) ** comment
23. Which keyword declares a variable in JavaScript?
a) var
b) let
c) const
d) All of the above
24. Which method is used to display an alert box?
a) alert()
b) popup()
c) msg()
d) display()

25. How do you call a function in JavaScript?


a) function myFunc
b) call myFunc()

[Link] 4/14
10/7/25, 3:39 PM Sample exam questions

c) myFunc()
d) execute myFunc()
26. What is the correct way to write an array in JavaScript?
a) var arr = (1,2,3)
b) var arr = [1,2,3]
c) var arr = {1,2,3}
d) var arr = <1,2,3>
27. Which event occurs when the user clicks on an HTML element?
a) onmouseclick
b) onclick
c) onchange
d) onpress
28. Which built-in method joins two or more arrays?
a) append()
b) concat()
c) attach()
d) join()
29. How do you write an IF statement in JavaScript?
a) if i = 5 then
b) if i == 5
c) if (i == 5)
d) if i = 5:
30. Which operator is used to assign a value to a variable?
a) =
b) ==
c) ===
d) :=

General Web Technologies & Protocols (31–40)


31. Which protocol is used to access a web page?
a) FTP
b) HTTP

[Link] 5/14
10/7/25, 3:39 PM Sample exam questions

c) SMTP
d) SNMP
32. Which of the following is NOT a web browser?
a) Chrome
b) Firefox
c) Internet Explorer
d) GitHub
33. What does URL stand for?
a) Uniform Resource Locator
b) Uniform Reference Link
c) Unified Resource Link
d) Universal Resource Locator

34. Which HTTP method is used to retrieve data?


a) POST
b) DELETE
c) GET
d) PUT
35. Which tag is used to include JavaScript code in HTML?
a) <script>
b) <js>
c) <javascript>
d) <code>

36. What is the default port for HTTP?


a) 80
b) 20
c) 25
d) 8080
37. Which database is commonly used with web applications?
a) Oracle
b) MySQL
c) PostgreSQL
d) All of the above
38. Cookies are stored on the:
a) Server

[Link] 6/14
10/7/25, 3:39 PM Sample exam questions

b) Browser
c) Database
d) Network

39. Which of the following is a server-side scripting language?


a) JavaScript
b) PHP
c) HTML
d) CSS

40. Which of the following is used to make a website responsive?


a) Java
b) Bootstrap
c) SQL
d) FTP

Would you like the answer key for these MCQs or a printable PDF version?

answer both the first and second ones

Great! Here's the full answer key for the first 40 MCQs on Web Technology. This covers
the HTML, CSS, JavaScript, protocols, and general web concepts.

Web Technology MCQs with Answers

HTML (Q1–Q10)
1. Which tag is used to define an HTML document?
b) <html>

2. What does HTML stand for?


c) Hyper Text Markup Language
3. Which tag is used to insert an image in HTML?
c) <img>

[Link] 7/14
10/7/25, 3:39 PM Sample exam questions

4. What attribute is used to provide an alternative text for an image?


a) alt

5. Which tag is used to create a checkbox in HTML?


c) <input type="checkbox">

6. What does the <br> tag do?


b) Inserts a line break

7. Which element is used for the largest heading in HTML?


c) <h1>

8. Which tag is used to create a hyperlink?


b) <a>

9. The correct HTML tag for inserting a line horizontally is:


b) <hr>

10. How can you create an ordered list in HTML?


b) <ol>

CSS (Q11–Q20)
11. What does CSS stand for?
c) Cascading Style Sheets
12. Which property is used to change the text color?
c) color
13. Which CSS property controls the text size?
c) font-size

14. How do you insert a comment in CSS?


c) /* this is a comment */
15. Which CSS property is used to set the background color?
c) background-color

16. How do you make a class in CSS?


b) .classname

17. Which selector selects all <p> elements inside a <div> ?


b) div p

18. Which property is used to make text bold?


b) font-weight: bold;

[Link] 8/14
10/7/25, 3:39 PM Sample exam questions

19. Which unit is relative to the font size of the element?


b) em

20. Which is the correct syntax for an ID selector in CSS?


b) #idname

JavaScript (Q21–Q30)
21. Which of the following is a JavaScript data type?
d) All of the above

22. What symbol is used for comments in JavaScript?


b) // comment

23. Which keyword declares a variable in JavaScript?


d) All of the above

24. Which method is used to display an alert box?


a) alert()

25. How do you call a function in JavaScript?


c) myFunc()

26. What is the correct way to write an array in JavaScript?


b) var arr = [1,2,3]

27. Which event occurs when the user clicks on an HTML element?
b) onclick

28. Which built-in method joins two or more arrays?


b) concat()

29. How do you write an IF statement in JavaScript?


c) if (i == 5)

30. Which operator is used to assign a value to a variable?


a) =

General Web Technologies & Protocols (Q31–Q40)


31. Which protocol is used to access a web page?
b) HTTP

[Link] 9/14
10/7/25, 3:39 PM Sample exam questions

32. Which of the following is NOT a web browser?


d) GitHub

33. What does URL stand for?


a) Uniform Resource Locator

34. Which HTTP method is used to retrieve data?


c) GET

35. Which tag is used to include JavaScript code in HTML?


a) <script>

36. What is the default port for HTTP?


a) 80

37. Which database is commonly used with web applications?


d) All of the above

38. Cookies are stored on the:


b) Browser

39. Which of the following is a server-side scripting language?


b) PHP

40. Which of the following is used to make a website responsive?


b) Bootstrap

Would you like this formatted into a PDF or Word document for printing or study?

yes

To generate a downloadable PDF or Word version, you'll need to log in to ChatGPT to use
the ChatGPT canvas feature. Once you're logged in, I can help create and format the
document for easy export.

Would you like me to show you a preview of how the document will look?

[Link] 10/14
10/7/25, 3:39 PM Sample exam questions

answer section B, C, and D

Certainly! Here's a full set of answers for Sections B, C, and D of the Web Technology
exam questions provided earlier.

Section B: Short Answer Questions – Answers


1. What is the difference between HTML and XHTML?
HTML (HyperText Markup Language) is more lenient in syntax and allows minor
errors in markup.

XHTML (Extensible HyperText Markup Language) is stricter and follows XML rules
(e.g., all tags must be properly closed and nested).

2. Explain the role of CSS in web development.


CSS (Cascading Style Sheets) is used to style and layout web pages — including
colors, fonts, spacing, positioning, and responsive design — separately from the
HTML content structure.

3. What are the different types of lists in HTML?


Ordered List ( <ol> ): Numbered items.

Unordered List ( <ul> ): Bulleted items.

Description List ( <dl> ): Contains terms ( <dt> ) and descriptions ( <dd> ).

4. Define the DOM (Document Object Model) and its use in web programming.
The DOM is a programming interface for HTML and XML documents. It represents the
document as a tree structure where each node is an object. JavaScript uses the DOM
to dynamically access and update content, structure, and styles.
5. What is the difference between GET and POST methods in form submission?

GET appends data in the URL; suitable for small, non-sensitive data.

POST sends data in the body of the request; suitable for secure and large data
submissions (e.g., login forms).

Section C: Descriptive / Long Answer Questions – Answers

[Link] 11/14
10/7/25, 3:39 PM Sample exam questions

1. Describe the client-server architecture in web technology. How does a browser


communicate with a web server?
In client-server architecture:

Client (browser) requests resources (e.g., web pages).

Server processes the request and sends a response (HTML, CSS, JS, etc.).
Communication uses HTTP/HTTPS protocols.
Example: User types URL → DNS resolves domain → HTTP GET request sent →
server responds with webpage.
2. Write a simple HTML document that includes a form with two input fields
(username and password) and a submit button.

<!DOCTYPE html> <html> <head> <title>Login Form</title> </head> <body>


<h2>Login</h2> <form action="/submit" method="POST"> Username: <input
type="text" name="username"><br><br> Password: <input type="password"
name="password"><br><br> <input type="submit" value="Login"> </form>
</body> </html>

3. Explain the box model in CSS with a diagram. Describe how margin, border,
padding, and content are related.

The CSS box model describes how elements are structured in terms of spacing and
layout:

| Margin |
|---------|
| Border |
|---------|
| Padding |
|---------|
| Content |

Content: The actual content of the box (text/image).


Padding: Space between content and border.
Border: The edge around the padding.

Margin: Space between the element and surrounding elements.


4. Discuss JavaScript event handling with examples. How can you handle a button
click using JavaScript?

[Link] 12/14
10/7/25, 3:39 PM Sample exam questions

JavaScript uses event listeners to handle events like clicks, keypresses, etc.

Example:

<button onclick="showMessage()">Click Me</button> <script> function


showMessage() { alert("Button was clicked!"); } </script>

Alternatively, you can use addEventListener() :

[Link]("btn").addEventListener("click", showMessage);

5. Compare and contrast static and dynamic websites. Give examples of technologies
used for each.

Feature Static Website Dynamic Website

Content Fixed, same for all users Changes based on user/request

Technologies HTML, CSS, JS PHP, [Link], [Link], MySQL

Example Portfolio site, blog template E-commerce site, social network

Speed Fast Slower (server processing involved)

Section D: Practical / Code-Based Questions – Answers


1. Write an HTML and CSS code to create a navigation bar with links to Home, About,
and Contact pages.

<style> .navbar { background-color: #333; overflow: hidden; } .navbar a {


float: left; display: block; color: white; text-align: center; padding:
14px 16px; text-decoration: none; } .navbar a:hover { background-color:
#ddd; color: black; } </style> <div class="navbar"> <a
href="[Link]">Home</a> <a href="[Link]">About</a> <a
href="[Link]">Contact</a> </div>

2. Write JavaScript code to validate a form where the email field must contain “@”
and a domain name.

<form onsubmit="return validateEmail()"> <input type="text" id="email"


placeholder="Enter your email"> <input type="submit" value="Submit">
</form> <script> function validateEmail() { var email =

[Link] 13/14
10/7/25, 3:39 PM Sample exam questions

[Link]("email").value; var pattern = /^[^\s@]+@[^\s@]+\.


[^\s@]+$/; if (![Link](email)) { alert("Invalid email address!");
return false; } return true; } </script>

3. Design a simple web page layout using CSS Grid or Flexbox.

Using Flexbox:

<style> .container { display: flex; } .box { width: 100px; height: 100px;


margin: 10px; background-color: teal; color: white; display: flex;
justify-content: center; align-items: center; } </style> <div
class="container"> <div class="box">1</div> <div class="box">2</div> <div
class="box">3</div> </div>

4. Create a responsive webpage using media queries that changes background color
based on screen width.

<style> body { background-color: lightblue; } @media (max-width: 768px) {


body { background-color: lightgreen; } } @media (max-width: 480px) { body
{ background-color: lightcoral; } } </style>

5. Using PHP, write code to fetch data from a database and display it in an HTML
table.

<?php $conn = new mysqli("localhost", "root", "", "mydatabase"); if


($conn->connect_error) { die("Connection failed: " . $conn-
>connect_error); } $sql = "SELECT id, name, email FROM users"; $result =
$conn->query($sql); echo "<table border='1'> <tr><th>ID</th><th>Name</th>
<th>Email</th></tr>"; if ($result->num_rows > 0) { while($row = $result-
>fetch_assoc()) { echo "<tr><td>" . $row["id"]. "</td><td>" .
$row["name"]. "</td><td>" . $row["email"]. "</td></tr>"; } } else { echo "
<tr><td colspan='3'>No data found</td></tr>"; } echo "</table>"; $conn-
>close(); ?>

[Link] 14/14

You might also like