0% found this document useful (0 votes)
1K views23 pages

Web Technology Exam Questions & Answers

The document outlines important questions related to web technology, categorized into short, medium, and long questions, covering topics such as HTML, JavaScript, JSP, Spring Framework, and RESTful services. It includes definitions, differences, and examples of various concepts like AOP, DOM, and session tracking. Additionally, it provides bonus revision topics and final suggestions for effective study preparation.

Uploaded by

Prashant Kumar
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)
1K views23 pages

Web Technology Exam Questions & Answers

The document outlines important questions related to web technology, categorized into short, medium, and long questions, covering topics such as HTML, JavaScript, JSP, Spring Framework, and RESTful services. It includes definitions, differences, and examples of various concepts like AOP, DOM, and session tracking. Additionally, it provides bonus revision topics and final suggestions for effective study preparation.

Uploaded by

Prashant Kumar
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

Web Technology Important Questions

SECTION A – Short Questions (2 marks each)


Likely to be asked:
1. What is AOP (Aspect Oriented Programming)?
2. Differentiate between HTML and HTML5.
3. Define Cookies.
4. What is the difference between let and var in JavaScript?
5. What are the advantages of JSP over Servlet?
6. Define API and CGI.
7. Differentiate between Spring and Spring Boot.
8. What do you mean by DOM?
9. What is IoC in Spring Framework?
10. List any two attributes of the <table> tag.

SECTION B – Medium-Length Questions (10 marks)

HIGHLY LIKELY

1. Explain the following HTML tags with example:


o <a>, <body>, <img>, <table>, <p>
(Asked in 2023, 2022)
2. Illustrate Document Object Model (DOM).
How to create a text box and button in DOM using JavaScript.
(Asked in 2023, 2022)
3. Explain Servlet life cycle in detail.
(Asked in 2024, 2023, 2022)
4. Illustrate Aspect Oriented Programming (AOP) in Spring Framework.
(Asked in 2024, 2023, 2022)
5. Classify and explain all annotations used in Spring Boot.
(Asked in 2023, 2022)
6. Design a HTML form for Library Management System or Corporate
Website.
(Asked in 2024, 2022)
7. Explain Bean life cycle. Is it controlled by Spring?
(Asked in 2024, 2022)

SECTION C – Long Questions (10 marks)

Choose from these most probable questions:


1. Write short note on HTTP methods:
GET, POST, PUT, DELETE
(2023, 2022)
2. Difference between Forward and SendRedirect in JSP
(2022)
3. Discuss session tracking. How is a session created? Explain with
example.
(2023, 2022)
4. Compare Constructor Injection and Setter Injection in Spring.
(2023)
5. Create a RESTful Spring Boot application to handle DELETE and PUT
request.
(2023)
6. Differentiate between DOM and COM.
(2024)
7. Write a JavaScript code to reverse digits of a number.
(2023)
8. Explain dependency injection in Spring Boot.
(2024)
9. How to save an image in a database using Spring Boot.
(2024)
10. Compare Client-Side and Server-Side Scripting.
(2023)

Bonus Revision Topics

• Cascading and types of CSS (Inline, Internal, External)


• Cookies vs Session
• JavaScript alert, confirm, prompt box
• Spring Boot project folder structure
• Difference between ApplicationContext and BeanFactory
• Create HTML page to change background color

Final Suggestion:

• Focus on HTML basics, JavaScript DOM, Servlet/JSP lifecycle, and


Spring Boot.
• Review at least one coding example each from HTML, JavaScript, and
Spring Boot.
• Practice difference-based questions – they are easy to learn and often
asked.
Answers:
1. What is AOP (Aspect Oriented Programming)?
AOP is a programming concept in Spring Framework used to separate cross-
cutting concerns (like logging, security, transactions) from the main business
logic.
It improves modularity by allowing separate code for features that affect
multiple parts of an application.

2. Differentiate between HTML and HTML5

Feature HTML HTML5

Version Older version of HTML Latest version of HTML

Needs plugins for


Multimedia Supports <audio> and <video> tags
audio/video

Doctype Long and complex Simple: <!DOCTYPE html>

Supports localStorage &


Storage Not supported
sessionStorage

Mobile Better mobile and responsive


Limited
support support

3. Define Cookies.
Cookies are small text files stored on a user's computer by a web browser.
They are used to store user data, like login details, shopping cart, or session
information, so the website can remember the user on future visits.

4. What is the difference between let and var in JavaScript?


var let

Function-scoped Block-scoped ({} based)

Can be redeclared Cannot be redeclared in same scope

Older way Modern (ES6) standard

5. What are the advantages of JSP over Servlet?


• Less Code: JSP is easier to write and needs less code than Servlets.
• Separation of Logic and UI: JSP allows HTML and Java code to be
written separately.
• Built-in objects: JSP provides default objects like request, response,
session, etc.
• Easy to maintain: Code in JSP is easier to manage and modify than
servlet code.

6. Define API and CGI.


• API (Application Programming Interface):
A set of rules that allows different software applications to
communicate with each other.
• CGI (Common Gateway Interface):
A standard way for web servers to run external programs (scripts) to
generate dynamic content (e.g., run a Python or PHP script from the
server).

7. Differentiate between Spring and Spring Boot


Feature Spring Framework Spring Boot

Setup Manual configuration Auto configuration

Deployment Needs external server (Tomcat) Has embedded server

Complexity More boilerplate code Less code, more features

Starter packs Not available Comes with built-in starters

8. What do you mean by DOM?


DOM (Document Object Model) is a tree-like structure that represents the
content of a web page.
It allows JavaScript to access and change HTML elements, attributes, and
styles dynamically.

9. What is IoC in Spring Framework?


IoC (Inversion of Control) is a concept where the control of object creation is
given to the Spring container instead of manually creating objects in the
code.
This helps in loose coupling and better dependency management.

10. List any two attributes of the <table> tag.


1. border – sets the border width of the table
Example: <table border="1">
2. cellpadding – sets space between cell content and border
Example: <table cellpadding="5">
Section B:

1. Explain the following HTML tags with example


Tags: <a>, <body>, <img>, <table>, <p>
• <a> (Anchor Tag):
Used to create hyperlinks.
Example:
<a href="[Link] Google</a>
• <body>:
Represents the main content of the webpage.
Example:
<body>
<h1>Welcome</h1>
</body>
• <img>:
Displays images.
Example:
<img src="[Link]" alt="Sample Image" width="200">
• <table>:
Used to create a table.
Example:
<table border="1">
<tr><th>Name</th><th>Age</th></tr>
<tr><td>John</td><td>25</td></tr>
</table>
• <p>:
Defines a paragraph.
Example:
<p>This is a paragraph of text.</p>

2. Illustrate Document Object Model (DOM)


What is DOM?
The DOM (Document Object Model) is a tree-like structure of an HTML
document. It allows JavaScript to access and change elements, attributes, or
content dynamically.
Create Text Box and Button Using JavaScript
<body>
<div id="formArea"></div>

<script>
// Create input
var input = [Link]("input");
[Link] = "text";
[Link] = "Enter your name";

// Create button
var btn = [Link]("button");
[Link] = "Click Me";
// Add both to div
var area = [Link]("formArea");
[Link](input);
[Link](btn);
</script>
</body>

3. Explain Servlet Life Cycle in Detail


A Servlet is a Java program that runs on a web server and handles web
requests.
Life Cycle Stages:
1. Loading and Instantiation:
The servlet class is loaded and an object is created by the container.
2. Initialization (init()):
Called once when servlet is first created. Used to initialize resources.
public void init() {
// Initialization code
}
3. Request Handling (service()):
Called every time a client sends a request.
It may call doGet() or doPost() methods depending on request type.
public void service(HttpServletRequest req, HttpServletResponse res) {
// Process request
}
4. Destruction (destroy()):
Called when servlet is about to be destroyed. Used to release
resources.
public void destroy() {
// Cleanup code
}

4. Illustrate Aspect Oriented Programming (AOP) in Spring Framework


AOP (Aspect-Oriented Programming) is a way to isolate common logic like
logging, security, or transaction handling from business code.
Key Concepts:
• Aspect: Common logic module (e.g., logging)
• Advice: When to apply aspect (before/after method)
• Pointcut: Specifies where to apply advice
• Join Point: Specific execution point in code
Example:
@Aspect
@Component
public class LoggingAspect {
@Before("execution(* [Link].*.*(..))")
public void logBefore() {
[Link]("Method is about to execute");
}
}
This logs every method in the service package before it runs.

5. Classify and Explain All Annotations Used in Spring Boot

Annotation Purpose

Main class, enables auto-configuration


@SpringBootApplication
and component scanning

@Component, @Service,
Marks a class as a Spring bean
@Repository, @Controller

@Autowired Injects dependencies

Combines @Controller and


@RestController
@ResponseBody for REST APIs

Maps HTTP methods to controller


@GetMapping, @PostMapping, etc.
methods

Binds request data to method


@RequestParam, @PathVariable
parameters

Injects values from


@Value
[Link]

@Configuration Indicates a configuration class

Declares a bean manually inside config


@Bean
class

6. Design a HTML form for Library Management System


<h2>Library Management Form</h2>
<form action="/submit" method="post">
<label>Student Name:</label>
<input type="text" name="studentName"><br><br>

<label>Book Title:</label>
<input type="text" name="bookTitle"><br><br>

<label>Issue Date:</label>
<input type="date" name="issueDate"><br><br>

<label>Return Date:</label>
<input type="date" name="returnDate"><br><br>

<input type="submit" value="Submit">


</form>

7. Explain Bean Life Cycle. Is it Controlled by Spring?


Yes, the Bean Life Cycle is managed by the Spring Container.
Steps in Bean Life Cycle:
1. Instantiation:
Spring creates an object using constructor.
2. Populate Properties:
Values are set using setters or constructor injection.
3. BeanNameAware, ApplicationContextAware (Optional):
Spring gives information about bean name/context.
4. @PostConstruct or afterPropertiesSet()
Called after bean is initialized.
5. Bean is Ready for Use
6. Destruction (@PreDestroy or destroy()):
Called before bean is removed (for cleanup).

Section C:
1. Write short note on HTTP methods: GET, POST, PUT, DELETE
• GET:
Used to fetch data from the server.
Data is sent in URL, not secure.
Example: GET /students
• POST:
Used to send data to the server to create a new resource.
Data is sent in body, more secure.
Example: POST /students with student details.
• PUT:
Used to update existing resource.
Example: PUT /students/1 updates student with ID 1.
• DELETE:
Used to remove a resource from the server.
Example: DELETE /students/1 deletes student with ID 1.

2. Difference between Forward and SendRedirect in JSP


Feature Forward SendRedirect

Control Forwarded internally (same Redirected externally (new


Flow server) request)

URL
URL doesn’t change URL changes in browser
Change

Speed Faster (internal) Slower (new request)

Use for passing request between Use when redirecting to


Use Case
pages another site

3. Discuss session tracking. How is a session created? Explain with


example.
Session tracking is used to keep track of user activities (like login, cart)
between requests.
Methods for Session Tracking:
• Cookies
• URL rewriting
• Hidden form fields
• HTTP Session (most common)
Creating Session in JSP:
<%
HttpSession session = [Link]();
[Link]("username", "John");
%>
• The server assigns a session ID to identify the user.
4. Compare Constructor Injection and Setter Injection in Spring

Feature Constructor Injection Setter Injection

Used In Constructor Setter method

Must provide all


Required Values Optional to set
dependencies

Immutable
Supports Doesn’t support
Objects

@Autowired on setter
Code Example @Autowired on constructor
method

Example:
// Constructor Injection
@Autowired
public Student(Service s) { [Link] = s; }

// Setter Injection
@Autowired
public void setService(Service s) { [Link] = s; }

5. Create a RESTful Spring Boot application to handle DELETE and PUT


request
@RestController
@RequestMapping("/students")
public class StudentController {
@PutMapping("/{id}")
public String updateStudent(@PathVariable int id, @RequestBody Student s)
{
return "Updated student with ID: " + id;
}

@DeleteMapping("/{id}")
public String deleteStudent(@PathVariable int id) {
return "Deleted student with ID: " + id;
}
}
• @PutMapping: For updating data
• @DeleteMapping: For deleting data

6. Differentiate between DOM and COM

DOM (Document Object


Feature COM (Component Object Model)
Model)

Use Used in Web (HTML/JS) Used in Windows programming

Represents webpage Enables communication between


Purpose
structure software

Access HTML using


Example COM objects used in MS Office, DLLs
JavaScript
7. Write a JavaScript code to reverse digits of a number
<script>
let num = 1234;
let rev = [Link]().split('').reverse().join('');
alert("Reversed number: " + rev);
</script>
• Converts number to string
• Splits, reverses, and joins digits

8. Explain Dependency Injection in Spring Boot


Dependency Injection (DI) means giving objects their dependencies
instead of creating them manually.
Spring Boot handles it automatically using annotations like @Autowired.
Why Use It?
• Less code
• Loose coupling
• Easy testing
Example:
@Service
public class StudentService {}

@RestController
public class StudentController {
@Autowired
StudentService studentService;
}

9. How to save an image in a database using Spring Boot


Steps:
1. Create REST API to accept image
2. Store image as byte[] or Blob in DB
Example Code:
@PostMapping("/upload")
public ResponseEntity<String> uploadImage(@RequestParam("file")
MultipartFile file) {
byte[] image = [Link]();
ImageEntity img = new ImageEntity();
[Link](image);
[Link](img);
return [Link]("Saved");
}

10. Compare Client-Side and Server-Side Scripting

Feature Client-Side Server-Side

Runs On User’s browser Web server

Languages JavaScript, HTML PHP, Java, Python, JSP

Speed Fast (no server call needed) Slower (needs server processing)
Feature Client-Side Server-Side

Security Less secure More secure

Example Form validation (JS) Login logic (PHP/Java)

Bonus Revision Topics:


1. Cascading and Types of CSS (Inline, Internal, External)
Cascading means that CSS rules are applied in a specific order if there is a
conflict. The order is:
1. Inline CSS (Highest priority)
2. Internal CSS
3. External CSS
4. Browser default

Types of CSS

Type Description Example

Inline CSS in the HTML tag <p style="color:red">Text</p>

Internal CSS inside <style> tag in <head>

<head>
<style>
p { color: blue; }
</style>
</head>
| External | CSS in a separate file (linked) |
html
CopyEdit
<link rel="stylesheet" href="[Link]">

2. Cookies vs Session

Feature Cookies Sessions

Stored On Client (browser) Server

Size Limit Small (~4 KB) Large

Security Less secure More secure

Lifetime Can be set manually Lasts until browser or server ends

Use Save user preference Save user login, shopping cart

3. JavaScript Alert, Confirm, and Prompt Boxes


• Alert Box: Shows a simple message.
alert("Hello user!");
• Confirm Box: Asks user to confirm Yes/No.
let result = confirm("Are you sure?");
• Prompt Box: Asks user to input data.
let name = prompt("What is your name?");
alert("Hello " + name);

4. Spring Boot Project Folder Structure


plaintext
project-name/

├── src/

│ └── main/

│ ├── java/

│ │ └── com/example/project/

│ │ ├── controller/

│ │ ├── service/

│ │ ├── model/

│ │ └── [Link]
│ └── resources/

│ ├── static/ → CSS, JS, images

│ ├── templates/ → HTML (Thymeleaf)

│ └── [Link]

└── [Link] (for Maven)

[Link] has the @SpringBootApplication annotation and is


the entry point.

5. Difference between ApplicationContext and BeanFactory


Feature BeanFactory ApplicationContext

Basic / Advanced container (extends


Basic container
Advanced BeanFactory)

Lazy loading of
Eager loading Eager loading of beans
beans

Support for AOP No Yes

Use case Simple apps Most Spring applications

6. Create HTML Page to Change Background Color


<!DOCTYPE html>
<html>
<head>
<title>Change Background</title>
<style>
body {
background-color: lightblue;
}
</style>
</head>
<body>
<h1>This page has a light blue background</h1>
</body>
</html>
You can also change it with JavaScript:
<script>
[Link] = "yellow";
</script>

Common questions

Powered by AI

Inversion of Control (IoC) in Spring Framework relinquishes the responsibility of object creation and management to the framework itself, enhancing modularity and reducing tight coupling. Dependency injection, a key aspect of IoC, automatically provides objects with their dependencies, either through constructors or setters. This facilitates better software design by decoupling component logic and fostering reusable, easily testable code. Spring handles dependency injection using annotations like @Autowired, simplifying the integration of different components .

Aspect Oriented Programming (AOP) in Spring allows developers to isolate cross-cutting concerns like logging, security, or transaction management from main application logic. This separation improves modularity by defining common logic in separate modules called aspects, which are applied at specified points (join points) in the application. AOP benefits application development by reducing code duplication, simplifying maintenance, and enhancing code readability and modularity .

HTML5 is an evolution of HTML and introduces features that significantly affect web development. HTML5 supports native multimedia (audio and video) with the <audio> and <video> tags without requiring plugins, offers better mobile support including responsive designs, and provides new storage options like localStorage and sessionStorage for offline web applications. These advancements simplify coding, enhance performance, and improve the user experience across web platforms .

Client-side scripting, which runs in the user's browser (e.g., JavaScript), offers faster performance and responsiveness as it doesn't require server communication for operations like form validation. However, it is less secure because code is visible to users. In contrast, server-side scripting (e.g., PHP, Java) is more secure, as it runs on the server and keeps sensitive logic hidden. It's optimal for operations like authentication or database interactions but adds latency due to server communication. Each paradigm is advantageous based on the operation: client-side for speed and interactivity, server-side for security and processing .

The Servlet life cycle includes stages of loading/instantiation, initialization, request handling, and destruction. Understanding these stages helps optimize web application development by ensuring resources are efficiently managed. During initialization (`init()` method), resources such as database connections can be established, while handling requests (`service()` method) efficiently balance tasks between `doGet()` and `doPost()` for optimal processing. Proper cleanup in the destruction phase (`destroy()` method) ensures resources are released, improving application stability and performance by preventing resource leaks .

Spring Boot streamlines the development process by offering auto-configuration and an embedded server setup, eliminating the need for extensive manual setup typical of the Spring Framework. It includes starter projects that simplify dependency management and enhance deployment ease, allowing developers to focus more on writing application logic. These features collectively reduce development time and effort, making Spring Boot particularly suitable for rapidly building production-ready applications .

JSP (JavaServer Pages) has several advantages over Servlets by allowing separation of business logic and presentation layers. It requires less boilerplate code and facilitates easier modifications due to its template-based approach, which integrates HTML with Java in a more intuitive manner. JSP also supports built-in objects like request and session, easing developer tasks. This separation improves maintainability and enables developers to update UI or logic independently without affecting other parts of the application .

CSS offers various styling benefits to web design, including improved style consistency, easier maintenance, and enhanced page loading times by separating content from design. With inline CSS, styles are applied directly within HTML elements providing the highest specificity but can reduce maintainability. Internal CSS, defined within the HTML <style> tags, applies styles to the same document but indirectly. External CSS, linked via a separate file, allows for centralized styling across multiple pages, promoting consistency and reducing redundant code. These types provide flexibility in managing styles based on project needs .

The DOM (Document Object Model) is a tree-like representation of an HTML document's structure, allowing JavaScript to dynamically access and manipulate elements, attributes, styles, and content. By using JavaScript, developers can alter the DOM to change webpage elements based on user interactions, such as displaying dynamically loaded content or updating styles, thus significantly enhancing user experience .

Creating a text box and a button using JavaScript involves manipulating the DOM to dynamically add elements. For instance, developers can use `document.createElement` to create input and button elements, set their properties, and append them to the DOM. This approach allows web applications to dynamically update the user interface in response to user actions without requiring server interaction, improving the responsiveness and interactivity of web applications .

You might also like