Given the following code in a stateful session bean business method;

try {
Socket skt = new Socket(x,y);
} catch (Exception ex) {
ex.printStackTrace();
}

assuming that x and y are the port and IP addresses respectively of a running service, which is running on the same server, which of the following is correct?

Options
- Failure in Compilation
- Failure in Deployment
- An exception is thrown at runtime
- Indeterminate. The code is not guaranteed to be ported to all EJB 2.0 container, though it may deploy.


CORRECT ANSWER : Indeterminate. The code is not guaranteed to be ported to all EJB 2.0 container, though it may deploy.

Discussion Board
Intermediate

The given answer is correct as stateful session bean is used to store the session of the client till client removes the bean. So, this code explains that it is trying to create a connection between two entities and as the exception parameters are also placed properly so the output will result in Indeterminate result. The code being used doesn't guarantee to be ported to all EJB 2.0 container, but it can be used for deployment purpose. It will create the connection and succeed but it will be hard to say if it can be ported as being portrayed.

Rohit Sharma 08-21-2014 06:32 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement