Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
46 views23 pages

Web Tech Important Questions With 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)
46 views23 pages

Web Tech Important Questions With 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
You are on page 1/ 23

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="https://www.google.com">Visit Google</a>
• <body>:
Represents the main content of the webpage.
Example:
<body>
<h1>Welcome</h1>
</body>
• <img>:
Displays images.
Example:
<img src="image.jpg" 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 = document.createElement("input");
input.type = "text";
input.placeholder = "Enter your name";

// Create button
var btn = document.createElement("button");
btn.innerText = "Click Me";
// Add both to div
var area = document.getElementById("formArea");
area.appendChild(input);
area.appendChild(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(* com.example.service.*.*(..))")
public void logBefore() {
System.out.println("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
application.properties

@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 = request.getSession();
session.setAttribute("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) { this.service = s; }

// Setter Injection
@Autowired
public void setService(Service s) { this.service = 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 = num.toString().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 = file.getBytes();
ImageEntity img = new ImageEntity();
img.setData(image);
repo.save(img);
return ResponseEntity.ok("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="style.css">

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/

│ │ └── ProjectApplication.java
│ └── resources/

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

│ ├── templates/ → HTML (Thymeleaf)

│ └── application.properties

└── pom.xml (for Maven)

ProjectApplication.java 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>
document.body.style.backgroundColor = "yellow";
</script>

You might also like