Java EE 5/6 EJB, JPA & Web Services (Legacy)
Legacy Java EE quiz covering EJB 3.0, session beans, message-driven beans, JPA, JAX-WS web services, and ORM frameworks. Note: These technologies use deprecated javax.* namespace; Jakarta EE 10/11 uses jakarta.* and EJB is deprecated in favor of CDI.
Questions
Which of the following is NOT true about ORM Frameworks?
- Application can be isolated from the database and the only connection to it is using the ORM framework and a JDBC driver.
- ORM Frameworks reduce development times
- Manageability of application increases
- It is faster than the direct JDBC access.
It provides a convenient way to bind an XML schema to a representation in Java code. This makes it easy for you to incorporate XML data and processing functions in applications based on Java technology without having to know much about XML itself. Which of the following is the API described above?
- JAXR
- JAXB
- JAXP
- SAAJ
Which of the following is NOT an advantage of Java EE Web Services Programming Model?
- Supports resource injection removing the burden of creating and initializing common resources in a Java runtime environment.
- Simplifies development/deployment of web services through annotations.
- Supports both SOAP 1.1 and SOAP 1.2
- A JAX-WS client can access a web service that is not running on the Java platform, and vice versa.
- None of the above.
What are two benefits of the new EJB 3.0 model?
- Session bean is a POJO managed by the EJB container.
- Stateless session beans require a home interface only.
- Callback methods can be defined either in the bean class itself or in a bean listener class.
- All session beans and message driven beans need to have a business interface
Which of the following is true about EJB3.0?
- Elimination of lifecycle callback methods.
- An interceptor facility for session beans and message-driven beans.
- Increased requirements for usage of checked exceptions.
- Now you can use standard SQL queries with Java Persistence API.
Which of the following offers an accurate description of Message-Driven Enterprise Beans?
- Message-Driven beans are just a new way of describing a JMS message. This has been formalized with the EJB 2.0 specification.
- A Message-Driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously.
- A Message-Driven bean is an enterprise bean that allows J2EE applications to process messages synchronously.
- A Message-Driven bean is used when you need to interact with messaging systems other than JMS.
- A Message-Driven bean is like a Session Bean except that if the server is busy it will put the Message-Driven beans' method requests in a queue and execute them one at a time to reduce the load on the Application Server.
What is the biggest difference between Message-Driven Beans and Entity and Session Beans?
- There is no difference in structure between Message-Driven Beans and Entity and Session Beans. They all have home, remote interfaces and a bean class.
- Message-Driven beans don't have a home interface.
- A Message Driven bean is different from Session Bean because its state is persisted.
- Clients do not access Message-Driven beans through interfaces.
What are reasons why you would use an ORM approach?
- Application can be isolated from the database and the only connection to it is using the ORM framework and a JDBC driver.
- Manageability of a Java application increases.
- They perform faster than direct JDBC connections.
- ORM supports same level of data access as SQL.
- ORM does little to improve developer productivity.
You are building a new Customer Relationship Management system. You have developed the design model and planning to choose persistence mechanism. The model has complex relationships between tables. You do not want any persistence mechanism code to be present in business objects.Which of the following technologies would you choose?
- Java Persistence API
- CMP entity bean
- BMP entity bean
- DAO
You are building a simple application which will read XML registries and display the Web Service details on the browser. Which of the following API would you use?
- JAXR
- JAXB
- JAXP
- SAAJ
You have developed an application consisting of Java EE Stateless session beans. Methods of these beans use simple Java types. You would like to convert them to web services. How can you achieve it?
- Update web.xml
- Use Resource Injection
- Use annotations
- Update ejb-jar.xml
Which of the following is FALSE about EJB3.0?
- Supports annotations
- Supports resource injection
- Simplifies enterprise bean types
- Gives interceptor facility for session, message-driven and entity Beans
You have defined transaction attributes for a particular method in the session bean class through annotations. You defined a different value in the deployment descriptor. If you have defined at both the places for a particular method, which settings take precedence?
- Annotations
- Deployment descriptor
- This is not possible as you cannot use both.
- It is specific to application server product
When should you use a Stateful Session Bean?
- When fetching frequently used read-only data.
- If you need to manage the workflow or several EJBs.
- At any time, multiple clients can have access to the bean instance.
- When the bean should represent a business entity.
- The bean needs to hold data about the client across multiple invocations.
- To asynchronously receive JMS messages.
When should you use a Session Bean?
- At any time, only one client has access to the bean instance
- At any time, multiple clients can have access to the bean instance
- When the bean should represent a business entity
- The bean is not required to be persistent
- To synchronously receive JMS messages
- To asynchronously receive JMS messages
EJB 3.0 offers simplified entity programming model. Which of the following describe these new simplified features with regard to EJB 3.0 and Java Persistence API?
- In EJB 3.0, persistent fields must be identified through deployment descriptor.
- The persistent state of an entity is represented either by its persistent fields or persistent properties.
- For an EJB 3.0 entity, you no longer need to code interfaces such as LocalAddressHome and LocalAddress.
- In the Java Persistence API, you do not not need to provide an XML descriptor to specify an entity's primary key.
- Java Persistence API is simplified by removing support for complex relationships between Entities.
There is an excellent open-source ORM framework available in the market. Your team suggests using this new framework. Which of the following is the main disadvantage of using this new framework?
- Application can be isolated from the database and the only connection to it is using the ORM framework and a JDBC driver.
- Developer productivity increases.
- Performance will be slower than direct JDBC connections.
- Application maintainance may be a problem.
Which two statements are FALSE about implementing web services utilizing the Java EE programming model?
- Supports the processing of XML content, data binding, and the development SOAP based and RESTful Web Services.
- Web Services exposed by JAX-WS can only be of type document/literal.
- Stateless session beans cannot be exposed as web services using Java EE technology.
- JAX-WS greatly simplifies the web service implementation model.
You are building a Java EE Stateless Session Bean with remote interfaces which you also would like to expose as a web service. Which of the following is false?
- When EJB is called by client, parameters will be passed by reference
- Methods must have RMI-IIOP compatible parameters and return types
- Methods must have JAXB compatible parameters and return types
- Use annotation @WebService and @WebMethod for deployment.
You would like to measure the performance (response time) of a particular business method of EJB3.0 Session Bean. Which of the following facilitates the same?
- Dependency Injection
- Interceptors
- Intercepting Filter Pattern
- None of the above. You need to write code for measuring response times.