2017 Enterprise Architecture Scheme
2017 Enterprise Architecture Scheme
1. (Total 20 Marks)
i. What is “Enterprise Computing”? (03 marks)
Computing that is distributed across the network which support the need to build
distributed, transactional, and portable applications that leverage the speed, security,
and reliability of server side technology.
ii. Briefly explain levels of the 3-tiered architecture using a suitable diagram.
(08 marks)
2 marks
JavaEE Application
Server
Web application
Web browser
Business
Logic
Database
Standalone
Application
2 *3 Marks
Client tier - client program makes requests to middle tier
Middle tier - handles client requests by processing
application data (business logic – business tier)
Data tier - persistent data store (database / legacy system / etc.)
iii. What is a J2EE component? Give two examples. (04 marks)
Self-contained functional software unit that is assembled into a J2EE application with its
related classes and files and that communicates with other components.
Eg: servlets, Java server pages, Javabeans, Enterprise Javabeans etc.
iv. Briefly explain the term Web Application Framework. Give two examples for Java
Web Application Frameworks. (05 marks)
3 Marks
Web application framework (WAF) is a software framework that is designed to support the
development of web applications including web services, web resources, and web APIs. Web
frameworks provide a standard way to build and deploy web applications.
Example (1*2 Marks )
Spring, JSF, GWT, Grails, Struts, Dropwizard, JHipster, jax-rs, Vaadin, Seam, Wicket,
Tapestry etc
2. (Total 20 Marks)
i. What is concurrency? (03 marks)
Concurrency is the ability to run several programs or several parts of a program in
parallel.
ii. How to implement Threads in java? Explain each method using Java code segments.
(08 marks)
2 ways
1. By extending the Thread class
public class HelloThread extends Thread {
public void run() {
System.out.println("Hello from a thread!");
}
iii. Briefly explain the importance of thread synchronization in Java. (03 marks)
Thread synchronization, coordinates access to shared data by multiple concurrent
threads.
Ensures that each thread accessing a shared object excludes all other threads from
doing so simultaneously.
iv. Java provides two approaches in scheduling threads. What are they? Briefly explain
each. (06 marks)
Preemptive
The highest priority task executes until it enters the waiting or dead states or a
higher priority task comes into existence. (Thread.setPriority( int priority)
3. (Total 20 Marks)
i. What is a JDBC driver? (02 marks)
Set of classes that interface with a specific database engine.
ii. The following Java programme performs a simple query on the DreamHome database. It
retrieves all the data in the Product table and displays them. Fill the blanks with suitable
Java codes. (09 marks)
import java.sql.*;
public class viewProducts{
static final String url=("jdbc:mysql://localhost/Dreamhome","root"," ");
String sql = "SELECT product_ID, description, unit FROM Product";
public static void main(String[] args) {
try{
// Load JDBC driver
a. ………………………………………………………………
// Make connection
b. ………………………………………………………………
// Create statement
c. ………………………………………………………………
// Execute query
d. ………………………………………………………………
// Process the result
e. ………………………………………………………………
f. ………………………………………………………………
//Ensure connection, statement, result set are closed.
iv. What is Hibernate? What are the advantages of Hibernate over JDBC?
(05 marks)
- Hibernate is java based ORM (Object-relational mapping) tool that provides
framework for mapping application domain objects to the relational database tables
and vice versa. (03 Marks)
- Advantages (02 Marks for any correct advantage)
• Hibernate is data base independent, same code will work for all data bases like
ORACLE,MySQL ,SQLServer etc. In case of JDBC query must be data base specific.
• As Hibernate is set of Objects, you don't need to learn SQL language.
You can treat TABLE as a Object. In case of JDBC you need to learn SQL.
• Hibernate removes a lot of boiler-plate code that comes with JDBC API, the code
looks cleaner and readable.
• Hibernate supports inheritance, associations and collections. These features are not
present with JDBC API.
4. (Total 20 Marks)
i. What is an XML parser? Give two (02) examples for Java XML parsers. (04 marks)
A XML parser is a program that reads a XML document, checks whether it is
syntactically correct, and takes some actions as it processes the document.
]>
5. (Total 20 Marks)
i. What is Servlet container? Name three common tasks performed by Servlet
Container? (05
marks)
Model Answer [2 Marks]
Servlets run inside a special container called the servlet container as part of the same
process as the web server itself. It is an application server that provides the facilities for
running Java servlets
The servlet container is responsible for initializing, invoking, and destroying each servlet
instance.
ii. Write JSP code segment to create a function to calculate and print the cube of a given
number. Use JSP scriplets. . (05 marks)
<%!
int cube(int n){
return n*n*n*;
}
%>
iii. Name the four methods of session management in Servlets? (04 marks)
o Cookies are small files that the servlet can store on the client computer, and
retrieve later
o URL rewriting: You can append a unique ID after the URL to identify the user
o Hidden <form> fields can be used to store a unique ID
o Java’s Session Tracking API can be used to do most of the work for you
iv. The following index.html file has been provided to a user to input an integer.
<html>
<body>
<form action="NumServlet" method = "get">
import java.io.*;
import javax.servlet.*; 02 Marks
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet 02 Marks
{
02 Marks
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
out.println("<BODY>"); 04 Marks
out.println("<BIG>Hello World</BIG>");
out.println("</BODY>");
String num = request.getParameter("value");
int n = Integer.parseInt(num);
for (int i=0; i<=n; i++)
out.println(i);
out.println("</HTML>");
}
}
d. Java annotations
• Annotations, a form of metadata, provide data about a program that is not part of
the program itself. Annotations have no direct effect on the operation of the code
they annotate.
• Annotations have a number of uses, among them:
- Information for the compiler — Annotations can be used by the compiler to detect
errors or suppress warnings.
- Compile-time and deployment-time processing — Software tools can process
annotation information to generate code, XML files, and so forth.
- Runtime processing — Some annotations are available to be examined at runtime.
(12 marks)