๐Ÿ–ผ๏ธChapter 8 cover
Nepal Engineering Council ยท Registration ExaminationASoE ยท Ch 8
โ† Back to ASoE Syllabus
8

Chapter 8

Java Programming and Web Technology

ASOE08ยท6 Sub-topicsยท60 MCQs
๐ŸŽฏ Read MCQs Mode
8.1

Java basics and multithreading

ASoE0801
1
JVM (Java Virtual Machine) is an abstract, platform-dependent engine that executes compiled .class bytecode, enabling Java's write once, run anywhere portability.
2
JRE (Java Runtime Environment) = JVM + core class libraries โ€” everything needed to RUN a Java application, but NOT to compile one.
3
JDK (Java Development Kit) = JRE + development tools (javac, debugger, etc.) โ€” everything needed to both DEVELOP and run Java applications.
4
Java OOP is built around classes and objects, supporting encapsulation, inheritance, polymorphism, and abstraction; Java allows single inheritance for classes but multiple inheritance only via interfaces.
5
A thread is the smallest unit of execution within a process; multithreading runs two or more threads concurrently to improve CPU utilization and responsiveness.
6
A thread can be created in Java two ways: (1) extend Thread and override run(), or (2) implement the Runnable interface and pass it to a Thread constructor โ€” the latter is generally preferred since Java permits only single class inheritance.
7
Calling interrupt() sets a thread's interrupt flag to signal it should stop or respond, without forcibly terminating it.
8
Thread priorities range from MIN_PRIORITY (1) to MAX_PRIORITY (10), with NORM_PRIORITY (5) as the default; priorities only hint to the scheduler and do NOT guarantee execution order.
9
The synchronized keyword ensures only ONE thread can execute a critical section (method/block) on a given object at a time, preventing race conditions on shared data.
10
Deadlock occurs when two or more threads are blocked forever, each waiting for a resource/lock held by another thread in the same waiting group.
11
Thread communication uses the Object class's wait(), notify(), and notifyAll() methods to let threads coordinate access to shared state.
12
The legacy suspend(), resume(), and stop() methods are deprecated because they are deadlock-prone; modern code uses flags combined with wait()/notify() or interrupt() instead.
13
The Java Collection Interface provides a unified architecture (List, Set, Map, Queue) for storing and manipulating groups of objects.
14
String objects are immutable; `StringBuilder` (not thread-safe, faster) and `StringBuffer` (synchronized/thread-safe) provide mutable character sequences. Calendar manipulates date/time fields, SimpleDateFormat formats/parses dates by pattern (e.g. "dd-MM-yyyy"); String.format(), NumberFormat, and DecimalFormat format numbers/currency; Random generates pseudo-random numbers.
8.2

Java swing, AWT, event handling and JDBC

ASoE0802
1
AWT (Abstract Window Toolkit) is Java's original, platform-dependent GUI toolkit, providing classes such as Frame, Panel, Button, Label, TextField, and Checkbox.
2
Components are added to or removed from a Container using its add() and remove() methods.
3
Responding to controls requires registering the appropriate listener so the program reacts when the user interacts with a control.
4
FlowLayout places components left to right, wrapping to a new row as needed (default for Panel).
5
BorderLayout divides the container into five regions โ€” North, South, East, West, Center (default for Frame).
6
GridLayout arranges components in a rectangular grid of equal-sized cells; CardLayout stacks components like a deck of cards, showing only one at a time; GridBagLayout is a flexible grid allowing components to span multiple rows/columns.
7
Java GUIs use the delegation event model: an event source (e.g. a button) generates an event object, which is delegated to a registered listener that handles it.
8
Event classes represent specific occurrences: ActionEvent (button click/menu selection), MouseEvent (mouse actions), KeyEvent (keyboard actions), WindowEvent (window state changes), ItemEvent (selection changes).
9
Event Listener Interfaces define the callback methods a class must implement to handle a given event type, e.g. ActionListener, MouseListener, KeyListener, WindowListener.
10
Mouse/keyboard events are handled via MouseListener/MouseMotionListener and KeyListener; action events from any component are handled by implementing ActionListener's actionPerformed() method.
11
AWT components are heavyweight (rely on native platform peers) with a look-and-feel fixed to the native platform, while Swing components are mostly lightweight (drawn by Java itself) with a pluggable, customizable look-and-feel.
12
Swing is built on top of AWT โ€” it reuses AWT's event-handling model and is layered over a minimal AWT container/windowing foundation; it is part of the Java Foundation Classes (JFC).
13
Swing components follow a modified MVC (Model-View-Controller) design, separating a component's data (Model) from its presentation (View) and interaction logic (Controller) โ€” this is what makes pluggable look-and-feel possible.
14
Common Swing components are prefixed with J (JButton, JLabel, JTextField, JCheckBox); common containers include JFrame, JPanel, and JScrollPane, used to hold and organize other components.
8.3

J2EE, servlet programming and JSP programming

ASoE0803
1
Core J2EE technologies include Servlets, JSP (JavaServer Pages), EJB (Enterprise JavaBeans), JDBC, JNDI, JMS, and RMI.
2
A typical enterprise application is multi-tier: Client tier (browser/app) โ†’ Web tier (servlets/JSP handling requests) โ†’ Business tier (EJB, business logic) โ†’ EIS/Data tier (databases and backend systems).
3
A J2EE Application Server supplies the runtime environment for enterprise applications โ€” examples include Apache Tomcat (servlet container), GlassFish, JBoss, WebLogic, and WebSphere.
4
GET requests append parameters to the URL, have limited data length, are cacheable/bookmarkable and idempotent โ€” data is visible in the URL.
5
POST requests send parameters in the request body, can send much larger amounts of data, are NOT cached by default, and are used for actions that change state (e.g. form submissions).
6
The Web Container is the part of the application server that manages the lifecycle of servlets and JSPs, and handles request/response processing, threading, and security on their behalf.
7
A Servlet is a Java class that extends server capabilities, handling HTTP requests and producing responses; it runs inside a web container.
8
The Deployment Descriptor (web.xml) is the configuration file describing how a web application should be deployed: servlet mappings, URL patterns, initialization parameters, and session configuration.
9
Steps for writing a servlet: extend HttpServlet โ†’ override doGet()/doPost() โ†’ compile โ†’ configure (via web.xml or annotations, mapping to a URL pattern) โ†’ deploy to the web container โ†’ access via mapped URL.
10
Since HTTP is stateless, session management techniques maintain state across requests: Cookies, URL rewriting, hidden form fields, and the HttpSession object (the most common approach).
11
Request dispatching uses the RequestDispatcher interface: forward() transfers control internally to another resource (client is unaware), while include() includes the output of another resource within the current response.
12
JSP (JavaServer Pages) lets Java code be embedded directly within HTML using special tags (<% ... %>); on first request, the container compiles the JSP page into an ordinary servlet.
13
A JavaBean is a reusable Java component following naming conventions: private fields, public getter/setter methods, and a no-argument constructor.
14
JSP works with beans via the tags <jsp:useBean>, <jsp:setProperty>, and <jsp:getProperty>.
8.4

Introduction to web technology

ASoE0804
1
Web technology is the combination of protocols and tools used to build, deliver, and run websites and web applications; it has evolved from static HTML pages (early Web) toward dynamic, interactive applications (modern Web).
2
The client-server architecture is the basic model underlying the web: a client (browser) sends a request, and a server processes it and returns a response.
3
HTML5 introduced semantic structural tags such as <header>, <footer>, <article>, <section>, <nav>, as well as <canvas>, <video>, and <audio> for rich media without plugins.
4
CSS3 adds animations, transitions, flexbox, and grid layout, along with media queries that enable responsive design โ€” layouts that adapt to different screen sizes.
5
Browser compatibility ensures a website renders and behaves consistently across different browsers and versions.
6
XML (eXtensible Markup Language) is a markup language for storing and transporting structured data using user-defined tags.
7
DTD (Document Type Definition) defines the legal structure, elements, and attributes that a valid XML document must follow.
8
XSLT (eXtensible Stylesheet Language Transformations) transforms an XML document into another format, such as HTML or plain text.
9
XHTML is a stricter, XML-compliant reformulation of HTML, requiring well-formed markup.
10
Cryptography secures data via encryption (converting plaintext to ciphertext using a key) and decryption (reversing the process).
11
Authentication verifies the identity of a user or system, typically via passwords, tokens, or certificates.
12
A digital certificate binds a public key to a verified identity, issued by a trusted Certificate Authority (CA); a digital signature uses asymmetric cryptography to prove the authenticity and integrity of a message or document.
13
SSL (Secure Socket Layer) is a protocol that provides encrypted communication between a client and a server over the web (largely superseded today by TLS).
14
A VPN (Virtual Private Network) creates a secure, encrypted tunnel across a public network, allowing remote, private access to another network.
8.5

Client and server-side scripting

ASoE0805
1
JavaScript is a client-side scripting language that runs in the browser to add interactivity to web pages; it supports the usual operators (arithmetic, comparison, logical) and control statements (if/else, loops, switch).
2
The DOM (Document Object Model) represents an HTML page as a tree of objects that JavaScript can read and modify, enabling dynamic content updates.
3
JavaScript supports Arrays and Objects for structured data, and (via ES6) class/object syntax for object-oriented style code.
4
Smart forms refer to client-side form validation โ€” checking user input in the browser before it is submitted to the server, giving instant feedback.
5
jQuery is a JavaScript library that simplifies DOM manipulation, event handling, and animations, using the compact $() function.
6
jQuery's element finder uses CSS-like selector syntax (e.g. ("#id"), (".class")) to locate elements.
7
jQuery provides simple methods for events and animations, such as .click(), .hide()/.show(), .fadeIn()/.fadeOut(), and .animate().
8
PHP is a server-side scripting language typically embedded within HTML, executed on the server before the page is sent to the client.
9
PHP supports operators, control statements, arrays, functions, string operations, math functions, and regular expressions (via functions like preg_match()), plus exception handling (try/catch); it also supports full OOP: classes, objects, inheritance, and polymorphism.
10
Session management uses session_start() and the $_SESSION superglobal to persist data across requests for a given user.
11
Database connectivity (e.g. via mysqli or PDO) allows PHP to perform CRUD operations (Create, Read, Update, Delete) against a database using SQL.
12
PHP can work with files using functions like fopen(), fread(), fwrite(), and fclose(), and manages memory automatically through built-in garbage collection.
13
Magic quotes was a (now removed) legacy PHP feature that automatically escaped user input to help prevent SQL injection; modern PHP instead uses prepared statements. PHP is the foundation of many Content Management Systems (CMS) โ€” such as WordPress.
14
JavaScript is client-side (runs in the browser), manipulates the page after it is loaded (DOM), and cannot directly access server-side databases; PHP is server-side (runs on the web server), generates page content before it is sent to the browser, and can connect directly to databases to perform CRUD operations.
8.6

JDBC

ASoE0806
1
JDBC (Java Database Connectivity) is a Java API that lets Java applications connect to, and interact with, relational databases using SQL.
2
Type 1 โ€” JDBC-ODBC Bridge: translates JDBC calls into ODBC calls; requires an ODBC driver installed on the client; largely obsolete.
3
Type 2 โ€” Native-API Driver: converts JDBC calls into database-specific native API calls; requires native client-side libraries.
4
Type 3 โ€” Network Protocol Driver: sends JDBC calls to a middleware server, which translates them to the database's protocol; pure Java, no client-side database library needed.
5
Type 4 โ€” Thin/Pure Java Driver: converts JDBC calls directly into the database's own network protocol; pure Java, platform-independent; the most widely used type today.
6
DriverManager manages the list of database drivers and establishes a connection via getConnection().
7
Connection represents an active connection/session with a specific database; SQLException is the exception thrown to report database access errors.
8
Statement / PreparedStatement / CallableStatement are used to send SQL statements to the database; ResultSet represents the table of results returned by executing a SQL query; ResultSetMetaData provides metadata about a ResultSet's columns (count, names, types).
9
`Statement` executes a static SQL statement with no parameters, recompiled by the database on every execution; `PreparedStatement` is precompiled, supports parameters (placeholders ?), is faster for repeated execution, and helps prevent SQL injection.
10
CallableStatement is used to call a stored procedure in the database.
11
A ResultSet provides methods such as next() (advance to the next row) and typed getters like getString()/getInt() to retrieve column values; it can be forward-only or scrollable depending on how it was created.
12
CRUD operations โ€” Create (SQL INSERT), Read (SQL SELECT), Update (SQL UPDATE), Delete (SQL DELETE) โ€” are performed via executeUpdate() (for INSERT/UPDATE/DELETE) or executeQuery() (for SELECT, which returns a ResultSet).
13
Typical JDBC workflow: load the driver โ†’ open a connection with DriverManager.getConnection() โ†’ create a Statement/PreparedStatement โ†’ execute the SQL โ†’ process the ResultSet (if any) โ†’ close the connection.