-------------------------------------------------------------------
Interview Question at Satyam for JAVA platform holding 3 yrs of Exp
-------------------------------------------------------------------
1) What is diffrence between StateFul and Stateless Session Bean?
A Stateful Session Bean is a bean that is designed to service business processes
that span multiple method requests or transactions. Stateful Session beans
retain state on behalf of an individual client. Stateless Session Beans do not
maintain state.
EJB containers pools stateless session beans and reuses them to service many
clients. Stateful session beans can be passivated and reused for other clients.
But this involves I/O bottlenecks. Because a stateful session bean caches client
conversation in memory, a bean failure may result in loosing the entire client
conversation. Therefore, while writing a stateful session bean the bean
developer has to keep the bean failure and client conversation loss in mind.
In case of stateless session beans, client specific data has to be pushed to the
bean for each method invocation which will result in increase in the network
traffic. This can be avoided in a number of ways like persisting the client
specific data in database or in JNDI. But this also results in I/O performance
bottlenecks.
If the business process spans multiple invocations thereby requiring a
conversation then stateful session bean will be the ideal choice. On the other
hand, if business process lasts only for a single method call, stateless session
bean model suits.
Stateful session beans remembers the previous request and responses. But
stateless beans do not. stateful does not have pooling concept, whereas the
stateless bean instances are pooled
-------------------------------------------------------------------
2) What is difference between BeanMangedPersistance and ContainerMangedPersistance?
CMP: Tx behaviour in beans are defined in transaction attributes of the methods
BMP: Programmers has to write a code that implements Tx behaviour to the bean class.
Tuned CMP entity beans offer better performance than BMP entity beans. Moving
towards the CMP based approach provides database independence since it does not
contain any database storage APIs within it. Since the container performs
database operations on behalf of the CMP entity bean, they are harder to debug.
BMP beans offers more control and flexibility that CMP beans.
Diff 1) In BMP you will take care of all the connection and you write the SQL
code inside the bean whereas in CMP the container will take care of it
Diff 2) The BMP is not portable across all DB's.whereas the CMP is
-------------------------------------------------------------------
(3)Draw and explain MVC architecture?
MVC Architecture is Module- View-Controller Architecture. Controller is the one
which controls the flow of application / services the requests from the View.
Module is the other layer which performs the exact operations. Each layer should
be loosely coupled as much as possible.
-------------------------------------------------------------------
(4)Difference between forward(request,response) and SendRedirect(url) in Servlet?
With Forward, request & response would be passed to the destination URL which
should be relative (means that the destination URL shud be within a servlet
context). Also, after executing forward method, the control will return back to
the same method from where the forward method was called. All the opposite to
the above points apply to sendRedirect.
(OR)The forward will redirect in the application server itself. It does not come
to the client. whereas Response.sendredirect() will come to the client and go
back ...ie. URL appending will happen.
-------------------------------------------------------------------
(5)What is Synchornize?
Synchronize is a technique by which a particular block is made accessible only
by a single instance at any time. (OR) When two or more objects try to access a
resource, the method of letting in one object to access a resource is called sync
-------------------------------------------------------------------
(6)How to prevent Dead Lock?
Using synchronization mechanism.
For Deadlock avoidance use Simplest algorithm where each process tells max number
of resources it will ever need. As process runs, it requests resources but never
exceeds max number of resources. System schedules processes and allocates resoures
in a way that ensures that no deadlock results.
-------------------------------------------------------------------
7)Explain different way of using thread? :
The thread could be implemented by using runnable interface or by inheriting
from the Thread class. The former is more advantageous, 'cause when you are
going for multiple inheritance..the only interface can help
-------------------------------------------------------------------
(8)what are pass by reference and passby value?
Pass By Reference means the passing the address itself rather than passing the
value. Passby Value means passing a copy of the value to be passed.
-------------------------------------------------------------------
(9)How Servlet Maintain Session and EJB Maintain Session?
Servlets maintain session in ServleContext and EJB's in EJBContext.
-------------------------------------------------------------------
(10)Explain DOM and SAX Parser?
DOM parser is one which makes the entire XML passed as a tree Structure and
will have it in memory. Any modification can be done to the XML.
SAX parser is one which triggers predefined events when the parser
encounters the tags in XML. Event-driven parser. Entire XML will not be stored
in memory. Bit faster than DOM. NO modifications can be done to the XML.
-------------------------------------------------------------------
(11)What is HashMap and Map?
Map is Interface and Hashmap is class that implements that and its not
serialized HashMap is non serialized and Hashtable is serialized
-------------------------------------------------------------------
(12)Difference between HashMap and HashTable?
The HashMap class is roughly equivalent to Hashtable, except that it is
unsynchronized and permits nulls. (HashMap allows null values as key and value
whereas Hashtable doesnt allow). HashMap does not guarantee that the order of
the map will remain constant over time.
-------------------------------------------------------------------
(12a) Difference between Vector and ArrayList?
Vector is serialized whereas arraylist is not
-------------------------------------------------------------------
(13)Difference between Swing and Awt?
AWT are heavy-weight componenets. Swings are light-weight components. Hence
swing works faster than AWT.
-------------------------------------------------------------------
14) Explain types of Enterprise Beans?
Session beans -> Associated with a client and keeps states for a client
Entity Beans -> Represents some entity in persistent storage such as a database
-------------------------------------------------------------------
15) What is enterprise bean?
Server side reusable java component
Offers services that are hard to implement by the programmer
Sun: Enterprise Bean architecture is a component architecture for the
deployment and development of component-based distributed business applications.
Applications written using enterprise java beans are scalable, transactional and
multi-user secure. These applications may be written once and then deployed on
any server plattform that supports enterprise java beans specification.
Enterprise beans are executed by the J2EE server.
First version 1.0 contained session beans, entity beans were not included.
Entity beans were added to version 1.1 which came out during year 1999.
Current release is EJB version 1.2
-------------------------------------------------------------------