Back to the 2019 paper
Module III: Basics of Web Programming
201914m
Write short notes on any two of the following:
(a) AWT
(b) Exception Handling
(c) DHTML and HTML
(d) API
Worked SolutionAI Assisted
Answer: Short Notes on Core Web & Java Concepts
(a) AWT (Abstract Window Toolkit)
AWT (java.awt) is Java's original, platform-dependent Graphical User Interface (GUI) toolkit introduced in JDK 1.0.
+-----------------------------+
| Component (Base Class) |
+--------------+--------------+
|
+------------------------+------------------------+
| |
v v
+--------------------+ +--------------------+
| Basic Controls | | Container |
| Button, Checkbox, | | (Panel, Window, |
| TextField, List | | Frame, Dialog) |
+--------------------+ +--------------------+
Key Architectural Characteristics:
- Heavyweight Peer Components: AWT components map directly to native operating system peer widgets (e.g., a
Buttonin AWT creates a Windows button on Windows and a Motif button on Solaris). - Container Hierarchy:
Frame: Top-level application window with title bar, border, and control icons.Panel: Nested container used to group and layout UI elements.
- Layout Managers: Automatically calculates layout coordinates across different screen resolutions (
BorderLayout,FlowLayout,GridLayout,GridBagLayout). - Event Delegation Model: Decouples event sources from event listeners using interfaces like
ActionListener,MouseListener, andKeyListener.
(b) Exception Handling in Java
Exception Handling in Java is a robust mechanism to intercept, handle, and recover from runtime errors (e.g., NullPointerException, ArithmeticException, IOException, SQLException), ensuring the normal flow of the application does not abruptly crash.
+-----------------------------+
| Throwable |
+--------------+--------------+
|
+------------------------+------------------------+
| |
v v
+--------------------+ +--------------------+
| Exception | | Error |
| (Can be Handled) | | (Unrecoverable OS/ |
| Checked & Unchecked| | JVM System Fail) |
+--------------------+ +--------------------+
The 5 Core Keywords:
try: Encloses code that might throw an exception.catch: Handles the specific thrown exception.finally: Executes cleanup code (closing files/connections) regardless of whether an exception occurred.throw: Explicitly throws a custom or standard exception instance.throws: Declares exceptions a method might throw to caller methods.
try {
int result = 50 / 0; // Throws ArithmeticException
} catch (ArithmeticException e) {
System.out.println("Error: Cannot divide by zero: " + e.getMessage());
} finally {
System.out.println("Cleanup executed regardless of exception.");
}
(c) Comparison: HTML vs. DHTML
| Parameter | HTML (HyperText Markup Language) | DHTML (Dynamic HTML) |
|---|---|---|
| Definition | Standard static markup language for structuring web pages. | Combination of HTML, CSS, JavaScript, and DOM. |
| Interactivity | Static display of text, images, and links. | Rich interactivity, client-side animation, drag-and-drop. |
| Server Dependence | Requires page refresh/server request to change content. | Updates content dynamically in-place without page reload. |
| Technologies | Pure HTML markup tags (<h1>, <p>, <table>). |
HTML + CSS Positioning + JavaScript + DOM API. |
| Complexity | Simple, easy to learn and parse. | Moderate to complex scripting logic. |
(d) API (Application Programming Interface)
An API (Application Programming Interface) is a formal set of defined rules, protocols, data structures, and functions that allows one software application to communicate, exchange data, and interact with another software system.
[ Client App / Frontend ] <==== (JSON / REST API over HTTP) ====> [ Server API / Database ]
Major Categories of APIs:
- Language / Library APIs: Built-in SDK classes (e.g., Java Collections API, Java Stream API, Python
mathmodule). - Web APIs (RESTful / GraphQL / SOAP): Network endpoints that exchange structured JSON/XML data over HTTP (e.g., Stripe Payment API, Google Maps API, Weather API).
- Operating System APIs: Low-level system routines providing hardware and file access (e.g., Windows Win32 API, POSIX system calls).
Key Benefits of APIs:
- Modularity & Reusability: Developers can integrate complex functionality (payments, maps, AI models) without building from scratch.
- Security & Controlled Access: Exposes only necessary data/endpoints while hiding internal implementation details and database logic.
Similar questions
Web TechnologyWrite short notes on the following : (a) HTML commands (b) DHTML dragging and drooping (c) AWT (d) JDBC202014mWeb TechnologyWhat do you understand by working layer in DHTML? Explain with the help of example.20197mWeb TechnologyHow can you do dragging and dropping data using DHTML? Explain with example.20197mWeb TechnologyDescribe the HTML code required for adding a form to a Web page.20197m