Computer Knowledge

Java Enterprise and Web Technologies

2,279 Questions

Java enterprise and web technologies questions focus on J2EE architecture, web services like SOAP, and servlet functionalities. These topics frequently appear in IT officer and specialist scale examinations. Regular practice ensures familiarity with enterprise application components.

HttpServlet methodsSOAP and web servicesEJB architecture rolesJ2EE componentsJSP servlet callingUDDI concepts

Java Enterprise and Web Technologies Questions

Multiple choice technology architecture
  1. Stateful session beans can survive a server crash but entity beans can't.

  2. Entity beans can survive a server crash but stateful session beans can't.

  3. Session beans are typically used to make calls on entity beans.

  4. Entity beans are typically used to make calls on session beans.

Reveal answer Fill a bubble to check yourself
B,C Correct answer
Explanation

Entity beans represent persistent data stored in a database and can survive server crashes because their state persists in storage. Stateful session beans maintain conversational state with a specific client only in memory and lose that state if the server crashes. Session beans typically handle business logic and make calls on entity beans for data operations, not the reverse.

Multiple choice technology architecture
  1. Local Clients should be used when the web server is running on the same machine as the application server.

  2. Local Clients should be used when session beans need to communicate with entity beans.

  3. Beans deployed in the same Virtual Machine as the client should use local Clients.

  4. Local Clients have been introduced to make testing code easier.

  5. Local Clients have been introduced to improve maintainability

  6. Local Clients have been introduced to improve performance.

Reveal answer Fill a bubble to check yourself
C,F Correct answer
Explanation

EJB 2.0 local client views allow beans in the same JVM to communicate without remote call overhead. Local clients were introduced to improve performance by eliminating RMI/IIOP overhead when client and bean are co-located. Local interfaces are required for beans in the same container, not merely on the same machine.

Multiple choice technology architecture
  1. JAXR

  2. JAXB

  3. JAXP

  4. SAAJ

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

JAXB (Java Architecture for XML Binding) provides the API described - it binds XML schemas to Java representations, allowing developers to work with XML data as Java objects without detailed XML knowledge. JAXR is for XML registries, JAXP is for parsing, and SAAJ is for SOAP attachments.

Multiple choice technology architecture
  1. Supports resource injection removing the burden of creating and initializing common resources in a Java runtime environment.

  2. Simplifies development/deployment of web services through annotations.

  3. Supports both SOAP 1.1 and SOAP 1.2

  4. A JAX-WS client can access a web service that is not running on the Java platform, and vice versa.

  5. None of the above.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

All the listed options (A, B, C, D) are actual advantages of Java EE web services programming model. Resource injection, annotations, multi-version SOAP support, and cross-platform interoperability are all benefits. Therefore 'None of the above' (E) is the correct answer.

Multiple choice technology architecture
  1. Session bean is a POJO managed by the EJB container.

  2. Stateless session beans require a home interface only.

  3. Callback methods can be defined either in the bean class itself or in a bean listener class.

  4. All session beans and message driven beans need to have a business interface

Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

EJB 3.0 benefits include: (A) Session beans became simple POJOs managed by the container, eliminating home and component interfaces. (C) Callback methods can be defined either in the bean class itself or in a separate listener class using annotations. B is false because stateless beans no longer require home interfaces. D is false because business interfaces became optional with business interface annotations.

Multiple choice technology architecture
  1. Elimination of lifecycle callback methods.

  2. An interceptor facility for session beans and message-driven beans.

  3. Increased requirements for usage of checked exceptions.

  4. Now you can use standard SQL queries with Java Persistence API.

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

EJB 3.0 introduced an interceptor facility for session beans and message-driven beans, allowing cross-cutting concerns to be applied declaratively. It also enhanced the Java Persistence API to support standard SQL queries through JPQL and native SQL. EJB 3.0 did NOT eliminate lifecycle callback methods (they became optional annotations), and it actually reduced the requirement for checked exceptions, not increased it.

Multiple choice technology architecture
  1. Message-Driven beans are just a new way of describing a JMS message. This has been formalized with the EJB 2.0 specification.

  2. A Message-Driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously.

  3. A Message-Driven bean is an enterprise bean that allows J2EE applications to process messages synchronously.

  4. A Message-Driven bean is used when you need to interact with messaging systems other than JMS.

  5. 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.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Message-Driven Beans (MDBs) are designed to process JMS messages asynchronously, allowing the EJB container to handle message consumption and bean invocation independently of client requests. This asynchronous processing is their defining characteristic. Option C incorrectly states they process messages synchronously. Option A is wrong because MDBs are enterprise beans, not just a way to describe JMS messages. Option D is incorrect because MDBs specifically work with JMS. Option E describes queue behavior which is not their primary purpose.

Multiple choice technology architecture
  1. 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.

  2. Message-Driven beans don't have a home interface.

  3. A Message Driven bean is different from Session Bean because its state is persisted.

  4. Clients do not access Message-Driven beans through interfaces.

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

Message-Driven Beans differ from Entity and Session Beans in two fundamental ways: they don't have home interfaces (only a bean class with annotations), and clients never access them directly through interfaces (remote or local). MDBs are invoked by the container when messages arrive, not by client calls. They also don't have component interfaces like Session/Entity beans. Option A is false because MDBs lack home and component interfaces. Option C is wrong because MDBs are stateless and don't persist state themselves.

Multiple choice technology architecture
  1. Java Persistence API

  2. CMP entity bean

  3. BMP entity bean

  4. DAO

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

For a CRM system with complex relationships and the requirement to keep business objects free of persistence code, Java Persistence API (JPA) is the best choice. JPA handles complex relationships through annotations (OneToMany, ManyToOne, etc.) and keeps persistence logic separate from business objects using the repository pattern or EntityManager. CMP 2.x entity beans are too complex and invasive. BMP requires persistence code in beans. DAO is a pattern, not a complete persistence solution like JPA.

Multiple choice technology architecture
  1. JAXR

  2. JAXB

  3. JAXP

  4. SAAJ

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

JAXR (Java API for XML Registries) is designed specifically for accessing business and technical registry information from XML-based registries like UDDI, ebXML, and others. Since the task involves reading XML registries to display web service details, JAXR is the appropriate API. JAXB is for XML binding to Java objects. JAXP is for general XML parsing (DOM/SAX/XSLT). SAAJ is for SOAP message handling.

Multiple choice technology architecture
  1. Update web.xml

  2. Use Resource Injection

  3. Use annotations

  4. Update ejb-jar.xml

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

EJB 3.0 simplifies converting stateless session beans to web services through annotations. By adding @WebService to the bean class and @WebMethod to business methods, the container automatically generates the WSDL and SOAP endpoints. This is much simpler than updating deployment descriptors (web.xml, ejb-jar.xml) or using resource injection (which is for dependencies, not web service configuration).

Multiple choice technology architecture
  1. Supports annotations

  2. Supports resource injection

  3. Simplifies enterprise bean types

  4. Gives interceptor facility for session, message-driven and entity Beans

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

EJB 3.0 supports annotations, resource injection, and simplifies enterprise bean types by removing home interfaces and using plain Java classes. These are all TRUE statements. However, the interceptor facility in EJB 3.0 is specifically defined for session beans and message-driven beans only, not entity beans. Entity beans in EJB 3.0 became JPA entities and use entity listeners for callbacks, not the interceptor facility. Thus statement D is FALSE and is the correct answer.

Multiple choice technology architecture
  1. Annotations

  2. Deployment descriptor

  3. This is not possible as you cannot use both.

  4. It is specific to application server product

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In EJB, deployment descriptor settings always override annotation configurations for the same method. The deployment descriptor provides externalized configuration that takes precedence, allowing administrators to modify behavior without changing code. This design pattern enables separation of development and operational concerns.

Multiple choice technology architecture
  1. When fetching frequently used read-only data.

  2. If you need to manage the workflow or several EJBs.

  3. At any time, multiple clients can have access to the bean instance.

  4. When the bean should represent a business entity.

  5. The bean needs to hold data about the client across multiple invocations.

  6. To asynchronously receive JMS messages.

Reveal answer Fill a bubble to check yourself
B,E Correct answer
Explanation

Stateful Session Beans maintain conversational state with a specific client across multiple method invocations. This makes them ideal for workflow management scenarios and representing business processes like shopping carts. The bean holds client-specific data throughout the interaction.

Multiple choice technology architecture
  1. At any time, only one client has access to the bean instance

  2. At any time, multiple clients can have access to the bean instance

  3. When the bean should represent a business entity

  4. The bean is not required to be persistent

  5. To synchronously receive JMS messages

  6. To asynchronously receive JMS messages

Reveal answer Fill a bubble to check yourself
A,D,E Correct answer
Explanation

Stateful Session Beans maintain exclusive access for one client at a time, preserving conversational state. Session beans are not required to be persistent - they're transient business logic components. They can synchronously consume JMS messages using JMS APIs directly.