Computer Knowledge

Java Enterprise and Web Technologies

2,183 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. 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.

Multiple choice technology architecture
  1. In EJB 3.0, persistent fields must be identified through deployment descriptor.

  2. The persistent state of an entity is represented either by its persistent fields or persistent properties.

  3. For an EJB 3.0 entity, you no longer need to code interfaces such as LocalAddressHome and LocalAddress.

  4. In the Java Persistence API, you do not not need to provide an XML descriptor to specify an entity's primary key.

  5. Java Persistence API is simplified by removing support for complex relationships between Entities.

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

EJB 3.0 entities can use field or property-based persistence access, specified by annotations rather than XML descriptors. The complex home/local interface requirements (Home/LocalHome) are eliminated. JPA supports complex relationships (one-to-many, many-to-many) and still uses annotations or XML for primary key specification.

Multiple choice technology architecture
  1. Supports the processing of XML content, data binding, and the development SOAP based and RESTful Web Services.

  2. Web Services exposed by JAX-WS can only be of type document/literal.

  3. Stateless session beans cannot be exposed as web services using Java EE technology.

  4. JAX-WS greatly simplifies the web service implementation model.

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

JAX-WS supports multiple SOAP binding styles including RPC/literal and document/literal, not just document/literal. Stateless session beans CAN be exposed as JAX-WS web services using @WebService annotation. Java EE web services do support XML processing and JAX-WS simplifies implementation.

Multiple choice technology architecture
  1. When EJB is called by client, parameters will be passed by reference

  2. Methods must have RMI-IIOP compatible parameters and return types

  3. Methods must have JAXB compatible parameters and return types

  4. Use annotation @WebService and @WebMethod for deployment.

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

Remote interface calls use pass-by-value semantics due to RMI serialization requirements, not pass-by-reference. Remote EJB methods require RMI-IIOP compatible parameters. Web service methods require JAXB-compatible types for XML serialization. @WebService and @WebMethod annotations are used to expose beans as web services.

Multiple choice technology architecture
  1. Dependency Injection

  2. Interceptors

  3. Intercepting Filter Pattern

  4. None of the above. You need to write code for measuring response times.

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

EJB 3.0 Interceptors (@AroundInvoke) provide cross-cutting concerns like performance measurement without modifying business logic. An interceptor method can record start/end timestamps around the business method execution. Dependency injection is for resource injection, not timing.

Multiple choice technology architecture
  1. You must write ejbPassivate() method. Shift the logic to this method.

  2. Mention the method name in the deployment descriptor

  3. Use annotations

  4. There is no such facility in EJB3.0

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

EJB 3.0 uses lifecycle callback annotations like @PrePassivate to handle passivation events. The annotated method is automatically invoked when the container passivates the bean. This eliminates the need to implement callback interfaces or use deployment descriptors.

Multiple choice technology web technology
  1. Applets

  2. JSP

  3. JSP/Servlets

  4. JSP/Servlets and EJBs

  5. You would never replace PHP scripts with a J2EE technology

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

JSP and Servlets are the core J2EE technologies for server-side web applications. JSP (JavaServer Pages) handles the presentation layer with dynamic content generation, while Servlets manage the request/response processing and business logic. This combination directly parallels PHP's server-side scripting role, making it the natural replacement. Applets are client-side Java programs, while EJBs handle enterprise business logic and transaction management - unnecessary for simple PHP replacement.

Multiple choice technology web technology
  1. DNS

  2. JAF

  3. Java Naming

  4. JNDI

  5. JNS

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

JNDI (Java Naming and Directory Interface) is the standard Java API for accessing directory and naming services like LDAP. It provides a unified interface to connect to various directory services, making it the correct choice for LDAP integration. DNS is for domain name resolution, JAF (Java Activation Framework) handles MIME type processing, and 'Java Naming' or 'JNS' are not standard J2EE technologies.

Multiple choice technology web technology
  1. You can access WebServices through Browser.

  2. JAX-WS provides support for development of RESTful WebServices.

  3. These WebServices can be consumed with help of AJAX

  4. WebService Interface can be defined through a standard vocabulary.

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

JAX-WS is designed for SOAP-based web services, whereas JAX-RS is the Java API for RESTful web services. Therefore, saying JAX-WS provides support for RESTful WebServices is false, making option B the correct choice for the false statement.

Multiple choice technology web technology
  1. JAXP

  2. JAXR

  3. UDDI

  4. JSSE

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

JAXP (Java API for XML Processing) is designed for parsing, validating, and processing XML documents, making it the appropriate tool to read the response XML before updating the database. UDDI and JAXR are used for discovering and registering web services, while JSSE secures communications via SSL/TLS.