Saturday, February 23, 2008

Interview Question at Satyam for JAVA Freshers

16)Services of EJB?

Database management :
?Database connection pooling
?DataSource, offered by the J2EE server. Needed to access connection pool of the server.
?Database access is configured to the J2EE server -> easy to change database / database driver

Transaction management :

?Distributed transactions
?J2EE server offers transaction monitor which can be accessed by the client.

Security management :

?Authetication
?Authorization 
?encryption



Enterprise java beans can be distributed /replicated into separate machines

Distribution/replication offers
?Load balancing, load can be divided into separate servers.
?Failover, if one server fails, others can keep on processing normally.
?Performance, one server is not so heavy loaded. Also, for example Weblogic has thread pools for improving performance in one server.


-------------------------------------------------------------------


17)When to choose EJB? 

Server will be heavy loaded :
?Distribution of servers helps to achieve better performance.

Server should have replica for the case of failure of one server:
?Replication is invisible to the programmer

Distributed transactions are needed "
?J2EE server offers transaction monitor that takes care of transaction management.
?Distributed transactions are invisible to the programmer

Other services vs. money :

Weblogic J2EE server ~ 80 000 mk and Jbuilder X Professional Edition ~ 5 000mk

-------------------------------------------------------------------

18)Why not to use free J2EE servers?

?no tecnical support
?harder to use (no graphical user interface ...)
?no integration to development tools (for example, Jbuilder)
?Bugs? Other problems during project?

-------------------------------------------------------------------


19) Alternative:Tuxedo
Tuxedo is a middleware that offers scalability services and transaction monitors.
C or C++ based.
Can be used with Java client by classes in JOLT package offered by BEA.

Faster that J2EE server?
Harder to program?
Harder to debug?

Implementation is platform dependent.

-------------------------------------------------------------------


20) J2EE server offers

DataSource:
?Object that can be used to achieve database connection from the connection pool.
?Can be accessed by the interface DataSource

Transaction monitor:
?Can be accessed by the interface UserTransaction.

Java Naming and the Directory Service :

-------------------------------------------------------------------


21)Java Naming and the Directory Service

Naming service is needed to locate beans home interfaces or other objects (DataSource, UserTransaction):
?For example, jndi name of the DataSource

Directory service is needed to store and retrieve properties by their name:
?jndi name: java:comp/env/propertyName

-------------------------------------------------------------------


22)XML ? deployment descriptor

ejb-jar.xml + server-specific xml- file Which is then Packed in a jar ? file 
together with bean classes.
Beans are packaged into EJB JAR file , Manifest file is used to list EJB?s and 
jar file holding Deployment descriptor.

-------------------------------------------------------------------


23) Session Bean

Developer programs three classes:
?Home interface, contains methods for creating (and locating for entity beans) bean instances.
?Remote interface, contains business methods the bean offers.
?Bean class, contains the business logic of the enterprise bean.


-------------------------------------------------------------------


24)Entity Beans

Represents one row in the database:
?Easy way to access database
?business logic concept to manipulate data.

Container managed persistence vs. bean managed persistence:

Programmer creates three or four classes:
?Home interface for locating beans
?Remote interface that contains business methods for clients.
?Bean class that implements bean?s behaviour.
?Primary key class ? that represents primary key in the database. Used to locate beans.
Primary key class is not needed if primary key is a single field that could

-------------------------------------------------------------------

25) When to use which bean?

Entity beans are effective when application wants to access one row at a time. 
If many rows needs to be fetched, using session beans can be better alternative
ava class (for example, Integer).

Entity beans are efficient when working with one row at a time
Cause a lot of network trafic.

Session Beans are efficient when client wants to access database directry.
?fetching/updating multiple rows from the database

-------------------------------------------------------------------



26) Explain J2EE Arch?

Normally, thin-client multitiered applications are hard to write because they 
involve many lines of intricate code to handle transaction and state management, 
multithreading, resource pooling, and other complex low-level details. 
The component-based and platform-independent J2EE architecture makes J2EE 
applications easy to write because business logic is organized into reusable 
components and the J2EE server provides underlying services in the form of a 
container for every component type. Because you do not have to develop these 
services yourself, you are free to concentrate on solving the business problem 
at hand. 

Containers and Services :
Component are installed in their containers during deployment and are the 
interface between a component and the low-level platform-specific functionality 
that supports the component. Before a web, enterprise bean, or application 
client component can be executed, it must be assembled into a J2EE application 
and deployed into its container. 
The assembly process involves specifying container settings for each component 
in the J2EE application and for the J2EE application itself. Container settings 
customize the underlying support provided by the J2EE Server, which include 
services such as security, transaction management, Java Naming and Directory 
InterfaceTM (JNDI) lookups, and remote connectivity.


Container Types :
The deployment process installs J2EE application components in the following 
types of J2EE containers. The J2EE components and container addressed in this 
tutorial are shown in Figure 5.
An Enterprise JavaBeans (EJB) container manages the execution of all 
enterprise beans for one J2EE application. Enterprise beans and their 
container run on the J2EE server. 
A web container manages the execution of all JSP page and servlet components 
for one J2EE application. Web components and their container run on the J2EE 
server. 
An application client container manages the execution of all application 
client components for one J2EE application. Application clients and their 
container run on the client machine. 
An applet container is the web browser and Java Plug-in combination running on 
the client machine