Blog
Enterprise Application Development Final Past Paper – UOS Main Campus
University of Sargodha main campus Enterprise Application Development final paper (120 minutes, all questions carry equal marks). Retyped from the original paper, with solved answers below.
Solved answers
Q1 – Multilayered architecture
Advantages: separation of concerns (presentation, business logic, data access); easier maintenance and testing; layers can be changed or replaced independently; code reuse; team members can work on different layers; better security (data layer not exposed directly).
Disadvantages: extra complexity and more code; some performance overhead because calls pass through several layers; changes that affect all layers take more effort; risk of “pass-through” layers that add little value.
Layer vs tier: a layer is a logical separation of code by responsibility (UI, business, data access) and can run in the same process on one machine. A tier is a physical separation — each tier runs on its own machine or process (client tier, application server tier, database server tier). A 3-layer application can be deployed as 1, 2 or 3 tiers.
Q2 – Applet vs Servlet
| Applet | Servlet |
|---|---|
| Runs on the client side, inside the browser (JVM plug-in) | Runs on the server side inside a web container (e.g. Tomcat) |
| Has a GUI (AWT/Swing) | No GUI; generates HTML/JSON responses |
| Downloaded to the client; restricted by the security sandbox | Not downloaded; has full server resources (database etc.) |
| Lifecycle: init, start, paint, stop, destroy | Lifecycle: init, service (doGet/doPost), destroy |
Applet advantages: rich interactive GUI in the browser; runs on the client, reducing server load; platform independent. Disadvantages: needs a Java plug-in (now removed from modern browsers — applets are deprecated); slow first load; sandbox restrictions; security concerns.
Q3 – Serialization
Serialization converts an object’s state into a byte stream so it can be saved to a file or sent over a network; deserialization rebuilds the object. A class becomes serializable by implementing the marker interface java.io.Serializable (fields marked transient are skipped).
class Student implements Serializable {
private static final long serialVersionUID = 1L;
String name; int roll;
transient String password; // not serialized
}
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
out.writeObject(student); // send over the network
Student s = (Student) new ObjectInputStream(socket.getInputStream()).readObject();Yes, serialized objects can be sent over a network (sockets, RMI), as long as the receiving side has the same class.
Q4 – Enterprise JavaBeans
EJB is a server-side component architecture of Java EE for building distributed, transactional, secure business logic. The EJB container provides transactions, security, pooling, concurrency and remote access, so developers focus on business logic.
- Session bean — performs business logic for a client (e.g. placing an order). Stateless (no client state), stateful (keeps conversational state) or singleton.
- Entity bean — represents persistent data in a database (e.g. a Customer row). In modern Java EE replaced by JPA entities.
- Message-driven bean — processes asynchronous messages from a JMS queue/topic (e.g. order-processing messages) without the client waiting.
Q5 – Web-tier MVC view design
In MVC the Model holds data and business logic (JavaBeans/EJB), the View presents data (JSP/JSF pages, templates), and the Controller (a front-controller servlet) receives requests, calls the model and selects the view. Good view design: views contain only presentation logic (use JSTL/EL tags, no Java code or database calls in JSP); use templates and composite views (header, menu, footer included in every page); keep one view per screen; pass data via request/session attributes or view helpers; support internationalisation; and keep views replaceable so the same model can be shown as HTML, JSON or mobile pages. Request flow: browser → controller servlet → model → controller forwards to the JSP view → HTML response.
