EJB interview question set 2/EJB Interview Questions and Answers for Freshers & Experienced

Explain the difference between Context, InitialContext and Session Context.

<> Context – An EJB context has all the information that is common to both the entity bean and the session.
<> InitialContext – This is a constructor providing the initial context.
<> Session Context – This has the required information for a session bean that it will need from a container.

What is EntityManager in EJB?

EJB has a mechanism called persistence. An EntityManager in EJB is a persistence interface that is used for performing operations like add, update, delete or find on a particular persistent entity. It is also used for executing queries through the Query interface.

Are entity beans allowed to create () methods?

Yes, it is allowed in cases where data is not inserted by using Java application.

Can more than a single table be mapped in CMP?

No, more than one table cannot be mapped in a single CMP.

How does EJB invocation take place?

Home Object reference is retrieved from the Naming Service via JNDI. Home Object reference is returned to the client. The steps are:

> Created a new EJB Object via Home Object interface.
> Created an EJB Object from the Ejb Object.
> Returned an EJB Object reference to the client.
> Invoked business method by using EJB Object reference.
> Delegate requested to Bean (Enterprise Bean).

What do you mean by EJBDoclet?

JavaDoc doclet, an open source is a doclet which generates good stuff related to EJB from comment tags of custom JavaDoc, which are embedded in the source file of EJB.

Is having static initializer blocks legal in EJB?

It is legal technically, but static initializer blocks have been used in executing pieces of code before the final execution of any method or constructor when a class is instantiated.

How can Enterprise JavaBeans be accessed from Active Server Pages?

Enterprise JavaBeans can be accessed from Active Server Pages by:

<> ‘Java 2 Platform’
<> Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0 which has been currently downloaded from the Sun Microsystems.

What do you mean by re-entrant? Can you say that session beans as re-entrant? Can entity beans be specified as re-entrant?

If the entity bean is defined as re-entrant, then it is possible by multiple clients to associate with the Entity bean and get methods executed concurrently inside the entity bean. Synchronization is taken care of by container. There is an exception thrown when an entity beam is defined as non-re-entrant and numerous clients are connected to it concurrently to carry out a method.

Differentiate, “find a method” from “select method” in EJB ?

A persistent field is returned by the select method of an entity bean that is related. A remote or local interface is returned by the finder method.

Define Clone?

Server group copies are defined as clone. But unlike Server Groups, clones are linked by means of nodes.

Define Ripple Effect?

During runtime, when the changes made in the various properties of server group, are propagated in every associated clone, this process is known as Ripple Effect.

What do you mean by in-memory replication?

When the contents having the memory of a single physical m/c are simulated in all m/c in that cluster, that process is called memory replication.

What Happens When You Invoke A Thread's Interrupt Method While It Is Sleeping Or Waiting?



When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.

Which Non-unicode Letter Characters May Be Used As The First Character Of An Identifier?


The non-Unicode letter characters $ and _ may appear as the first character of an identifier

How Can The Checkbox Class Be Used To Create A Radio Button?

By associating Checkbox objects with a CheckboxGroup.

If A Method Is Declared As Protected, Where May The Method Be Accessed?

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

When Is The Finally Clause Of A Try-catch-finally Statement Executed?

The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.

Enlist the technologies embraced in J2EE.

The technologies embraced in J2EE are:

Enterprise JavaBeansTM (EJBsTM)
JavaServer PagesTM (JSPsTM)
Java Servlets
The Java Naming and Directory InterfaceTM (JNDITM)
The Java Transaction API (JTA)
CORBA
The JDBCTM data access API.

When Does The Compiler Supply A Default Constructor For A Class?



The compiler supplies a default constructor for a class if no other constructors are provided.

How Does Multithreading Take Place On A Computer With A Single Cpu?

The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

Which Math Method Is Used To Calculate The Absolute Value Of A Number?

The abs() method is used to calculate absolute values.

What Is The Purpose Of The File Class?

The File class is used to create objects that provide access to the files and directories of a local file system.

What Is The Difference Between The Paint() And Repaint() Methods?

The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

What Is The Collection Interface?

The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.

What Advantage Do Java's Layout Managers Provide Over Traditional Windowing Systems?

Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

What An I/o Filter?


An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.

How Are The Elements Of A Gridlayout Organized?


The elements of a GridBad layout are of equal size and are laid out using the squares of a grid.

How Is It Possible For Two String Objects With Identical Values Not To Be Equal Under The == Operator?


The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.

What do you mean by ‘Hot deployment’ ?

The act of redeployment, deployment and un-deployment in Web logic when the server is running in EJB is called Hot Deployment.

Define ACID Properties?

ACID is Atomicity, Consistency, Isolation and Durability.

1. Atomicity: Operations that are bundled together and projected a single unit of job.
2. Consistency: Guarantees that after a transaction has taken place, there will be consistency.
3. Isolation: Helps protect viewing of other simultaneous incomplete transaction results.
4. Durability: Ensures durability by keeping a transitional log by which the permanent data be recreated by again applying the steps involved.

What Is The Difference Between The Jdk 1.02 Event Model And The Event-delegation Model Introduced With Jdk 1.1?

The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried. In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing required to support the bubbling of unhandled events.

What Is The Relationship Between A Method's Throws Clause And The Exceptions That Can Be Thrown During The Method's Execution?

A method's throws clause must declare any checked exceptions that are not caught within the body of the method.

What Class Of Exceptions Are Generated By The Java Run-time System?

The Java runtime system generates RuntimeException and Error exceptions.

What Class Allows You To Read Objects Directly From A Stream?

The ObjectInputStream class supports the reading of objects from input streams.

What Is The Difference Between A Field Variable And A Local Variable?


A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

Static variables in EJB should not be relied upon as they may break in clusters.Why?

Static variables are only ok if they are final. If they are not final, they will break the cluster. What that means is that if you cluster your application server (spread it across several machines) each part of the cluster will run in its own JVM.
Say a method on the EJB is invoked on cluster 1 (we will have two clusters – 1 and 2) that causes value of the static variable to be increased to 101. On the subsequent call to the same EJB from the same client, a cluster 2 may be invoked to handle the request. A value of the static variable in cluster 2 is still 100 because it was not increased yet and therefore your application ceases to be consistent. Therefore, static non-final variables are strongly discouraged in EJBs.

Why are ejbActivate() and ejbPassivate() included for stateless session bean even though they are never required as it is a nonconversational bean?

To have a consistent interface, so that there is no different interface that you need to implement for Stateful Session Bean and Stateless Session Bean.
Both Stateless and Stateful Session Bean implement javax.ejb.SessionBean and this would not be possible if stateless session bean is to remove ejbActivate and ejbPassivate from the interface.

Under What Conditions Is An Object's Finalize() Method Invoked By The Garbage Collector?

The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.

How Are This () And Super () Used With Constructors?


This() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

What Is The Difference Between A Choice And A List?


A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.

How Are The Elements Of A Gridbaglayout Organized?

The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.

Differentiate Phantom from Un-repeatable?

When data that did not existed before is inserted, it is read as phantom whereas when data that already existed is changed, un-repeatable occurs.

Differentiate Conversational from Non-conversational interactions?

The interaction between the client and the bean is called conversational while where multi method conversations are not held with clients it is known as non-conversational interactions.

How Can A Gui Component Handle Its Own Events?


A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

What Is The Highest-level Event Class Of The Event-delegation Model?


The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.

What Restrictions Are Placed On The Values Of Each Case Of A Switch Statement?

During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

What is the difference between JNDI context, Initial context, session context and ejb context.

JNDI context: provides a mechanism to lookup resources on the network.
Initial Context: it provides initial context to resources.
Session Context:it has all the information available which is required to session bean from the container.
EjbContext:it contain information which is required to both session and entity bean.

How can one EJB be called from within another EJB?

An EJB can be called within another EJB by using JNDI which can be used for locating the Home Interface and acquiring the instance.

Can remove () be a Stateless Session bean?

Yes, remove () can be a Stateless Session bean because the life remains the same till the method is executed.

Search
R4R Team
R4R provides EJB Freshers questions and answers (EJB Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,EJB interview question set 2,EJB Freshers & Experienced Interview Questions and Answers,EJB Objetive choice questions and answers,EJB Multiple choice questions and answers,EJB objective, EJB questions , EJB answers,EJB MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for EJB fresher interview questions ,EJB Experienced interview questions,EJB fresher interview questions and answers ,EJB Experienced interview questions and answers,tricky EJB queries for interview pdf,complex EJB for practice with answers,EJB for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .