This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “EJB 2.x with Spring”.
1. Key technology in developing distributed applications, especially multi-tier enterprise applications.
a) Remoting
b) EJB
c) RMI
d) All of the mentioned
View Answer
Explanation: Spring support for various remoting technologies, such as EJB, RMI, Hessian, Burlap, HTTP Invoker, and web services. Remoting is a key technology in developing distributed applications, especially multi-tier enterprise applications.
2. Java-based remoting technology that allows two Java applications running in different JVMs to communicate with each other.
a) Burlap
b) EJB
c) RMI
d) All of the mentioned
View Answer
Explanation: With RMI, an object can invoke the methods of a remote object. RMI relies on object serialization to marshall and unmarshall method arguments and return values.
3. To expose a service through RMI, you have to create the service interface that extends:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
View Answer
Explanation: Considering the typical RMI usage scenario, to expose a service through RMI, you have to create the service interface that extends java.rmi.Remote and whose methods declare throwing java.rmi.RemoteException.
4. To call the methods on a remote service:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
View Answer
Explanation: However, to call the methods on a remote service, you must handle java.rmi.RemoteException in case any exception is thrown by the remote service.
5. Spring remoting facilities can significantly simplify the RMI usage on both the server and client sides.
a) True
b) False
View Answer
Explanation: On the server side, you can use RmiServiceExporter to export a Spring bean as an RMI service whose methods can be invoked remotely. It’s just several lines of bean configuration without any programming. On the client side, you can simply use RmiProxyFactoryBean to create a proxy for the remote service.
6. There are several properties you must configure for an RmiServiceExporter instance:-
a) service name
b) service interface
c) service object
d) all of the mentioned
View Answer
Explanation: There are several properties you must configure for an RmiServiceExporter instance, including the service name, the service interface, and the service object to export.
7. By default, RmiServiceExporter attempts to look up an RMI registry at localhost port 1099.
a) True
b) False
View Answer
Explanation: If it can’t find the RMI registry, it will start a new one.
8. The Spring support classes facilitate building session beans:-
a) stateful session beans (SFSBs)
b) stateless session beans (SLSBs)
c) message-driven beans (MDBs)
d) all of the mentioned
View Answer
Explanation: The Spring support classes facilitate building session beans—stateful session beans (SFSBs) and stateless session beans (SLSBs)—and message-driven beans (MDBs) with Spring.
9. Spring EJB Support Classes for Different Types of EJB:-
a) AbstractStatelessSessionBean
b) AbstractStatefulSessionBean
c) AbstractMessageDrivenBean
d) All of the mentioned
View Answer
Explanation: Spring EJB Support Classes for Different Types of EJB
EJB Support Class EJB Type
AbstractStatelessSessionBean Stateless session bean
AbstractStatefulSessionBean Stateful session bean
AbstractMessageDrivenBean General message-driven bean that may not use JMS
AbstractJmsMessageDrivenBean Message-driven bean that uses JMS.
10. EJB support classes provide access to the Spring IoC container for you to implement your business logic in POJOs and wrap them with EJB components.
a) True
b) False
View Answer
Explanation: Because POJOs are easier to develop and test, implementing business logic in POJOs can accelerate your EJB development.
11. OpenEJB 3.1.1 supports:-
a) EJB 2.x components
b) EJB 3.0 and EJB 3.1 components
c) All of the mentioned
d) None of the mentioned
View Answer
Explanation: To compile and build your EJB component, you have to include a library that contains standard EJB classes and interfaces in your classpath. OpenEJB 3.1.1 supports both legacy EJB 2.x components as well as newer EJB 3.0 and EJB 3.1 components, so we’ll use its implementation library.
12. If you want to expose EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome.
a) True
b) False
View Answer
Explanation: If you want to expose this EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome instead, whose methods don’t need to throw RemoteException. For simplicity’s sake, we’re omitting the local and local home interfaces here.
13. The ejbCreate() method is the EJB hook for initialization of state, much as a JSR-250 annotated @PostConstruct() method or afterPropertiesSet() method work in Java EE 5 and Spring.
a) True
b) False
View Answer
Explanation: Similarly, for each overloaded form of ejbCreate() on the SessionBean, there must be a create method with the same arguments on the EJBHome.
14. To start the OpenEJB container, you first set environment variable:-
a) EJB_HOME
b) OPENEJB_HOME
c) Bashrc
d) None of the mentioned
View Answer
Explanation: To start the OpenEJB container, you first set the OPENEJB_HOME environment variable to point to your OpenEJB installation directory.
15. To use Spring EJB support for your EJB implementation classes, you have to include a few Spring framework JARs:-
a) spring-beans
b) spring-core
c) spring-context
d) all of the mentioned
View Answer
Explanation: To use Spring EJB support for your EJB implementation classes, you have to include a few Spring framework JARs, including spring-beans, spring-core, spring-context, spring-asm, and spring-expression in the classpath of your EJB container.
Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Spring Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books