EJB Interview Questions

EJB Interview Questions

These are some questions for the EJB interviews. Although you may have a good knowledge of EJB, you must revise the topics through answering questions. As EJB interviews are tough because the interviewers try to find the most talented developers in this field. So, to help you, we share some important questions that may help you in your interviews.

Download EJB Interview Questions PDF

EJB Interview Questions

Get $1500 – $6000 per DAY: http://webhop.se/5000perday49256

Creation of stateless EJB is done in simple steps:

  • First of all, you need to build a local interface
  • When it is done, the client application has to be used this interface.
  • And then, it needs to recognize the environment of the EJB. If the environment is same then use @Local annotation and if it different then use @Remote annotation
  • After that build a stateful session bean.
  • At last use @Stateful annotation to imply a stateful bean.

Yes, an EJB can be called from another EJB. The JNDI is used for this process which also used for locating the Home Interface and to receive instances.

It is not possible to have threading in EJB because Container maintains and controls the processing in EJB. And if threading is allowed in this, the container will be affected. As it is discussed earlier, EJB is designed to Lower the work on the developer and make them easier to just focus on business logic. EJB is not built to control the system or implementation works so container itself manage the thread.

Timer service is a method to construct a scheduled program. @Timeout is used in EJB 3.0 to maintain the EJB services in the beams such as stateless session beam and Message Driven beam too. Example of timer service is the generation of salary slips on any particular date of the month.

The transaction is the group of employment which works fully or none to integrate and maintain the data. The transaction has special properties like atomicity, consistency, integrity, durability together calls them ACID. The completed transaction is Commitment of successful performance over unsuccessful performance.

Transaction management can be done in two methods.

  • Declarative Transaction Management
  • Programmatic Transaction Management.

Below are the callback annotations for the stateless bean:

  • @PostConstruct - method is invoked when a bean is created for the first time.
  • @PreDestroy – When a bean is destroyed or displaced from the bean pool, this method is invoked.

Here is the list of callback annotation for an entity bean:

  • @PrePersist -This method is summoned when the entity is built in the database.
  • @PostPersist - This method is summoned after the entity is built in the database.
  • @PreRemove-This method is summoned when the entity is deleted from the database.
  • @PostRemove-This method is summoned when the entity is deleted from the database.
  • @PreUpdate-This method is summoned when the entity is updated in the database.
  • @PostLoad-This method is summoned when the entity is to be updated in the database.
The best women for sex in your town: http://jnl.io/bestadultdating42094
  • First, you need to build a database table
  • After that, build entity classes for the table
  • When it is done, you need to build data source and persistent unit
  • Then, build a stateless EJB
  • And then, Update it
  • At last, Console based application enters the stateless EJB.

Two components:

  1. Stateless session bean: It remains for a very short period of time. It is used when there is no need of worry of the state of the specific client. Validation of the credit card is a good example of the Stateless session beam.
  2. Stateful session beam: It has the unique feature which is absent in other beams that it can be implemented in the web whiles other cannot. It is used to maintain the conversation between the client. It saves the instance of conversation in the area like the hard disk before its proceeding into a passive state. Whenever the same client sends a request instance to come back to its original place (main memory). Online transaction, Online reservations are some examples of the Stateful session bean.

Here are some advantages of the Java beam:

  • First, the developer doesn't need to take care of the handling, load balancing, logging, persistence mechanism and much more. As these services are provided by the EJB container. This helps the developer to concentrate only on the business logic.
  • The beam is designed in a very genuine way so that it can be run on different part of the geographical areas. So large scale business can be developed.
  • EJB container looks after the creation or deletion of the EJB objects.

EJB stands for Enterprise java bean is a server-side software that is used to construct the module of enterprise software. It works on the container or we can say application server to scattered and business level application. Container plays a supporting function to transaction management and security that helps the developers and users to work on it easily. It is simple for them to concentrate on business logic.

On Occurrence of Application exception: EJB return the exception to client as it is intercepted. The method EJBContext().setRollBackOnly() specify that whether the transaction it should be rolled or not.

On Occurrence of System Exception: Here EJB first intercepts the transaction, rollback it and then initiate the clean-up tasks. It converts the exception into RemoteException before sending to the client.

Here are some annotations that are provided by the EJB.

  • OneToOne - The object that has one to one connection. For example, a person goes to buy a TV using a credit card.
  • OneToMany - The object that has one to many connections. For example, a cat has many kittens.
  • ManyToOne - The object that has many to one connection. For examples, A lot of passengers has a single train to visit destiny.
  • ManyToMany - The object that has many to many connections. For examples, A serial has many models and a model works in many serials.