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 web technology
  1. Servlet

  2. JSP

  3. EJB

  4. All the above

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

EJB (Enterprise JavaBeans) are specifically designed as business components in Java EE architecture. They encapsulate business logic. Servlets handle web requests/responses, JSP handles presentation - neither are business components.

Multiple choice technology web technology
  1. client side program

  2. server side program

  3. both a&b

  4. none

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

Servlets are server-side programs that run in a web container. They handle client requests, typically HTTP requests, and generate dynamic responses. They do NOT run on the client side.

Multiple choice technology architecture
  1. Request

  2. Session

  3. Application

  4. Page

  5. All

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

The jsp:useBean standard action supports four scope values: page, request, session, and application. Page scope is default and lasts only for the current page. Request scope lasts for the duration of the HTTP request. Session scope persists across multiple requests from the same user. Application scope is shared across all users and sessions. Since all four are valid options, 'All' is correct.

Multiple choice technology architecture
  1. JSP

  2. Servlet

  3. Both

  4. None of the above

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

In MVC1 architecture, the JSP page acts as the controller, handling both request processing and presentation. The JSP directly receives requests, contains business logic or calls helper beans, and generates the response. This page-centric approach mixes concerns but simplifies development for simple applications. A separate servlet controller is not used in MVC1.

Multiple choice technology architecture
  1. MVC2

  2. MVC1

  3. Both

  4. None of the above

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

MVC2 uses a servlet as a central controller, making it servlet-centric architecture. A single controller servlet receives all requests, determines the appropriate handler, invokes business logic, and selects the view for rendering. This separation provides better maintainability and testability compared to page-centric approaches.

Multiple choice technology architecture
  1. JSP

  2. Servlet

  3. Both

  4. None of the above

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

In MVC2 architecture, a servlet serves as the controller component. The controller servlet receives HTTP requests, delegates business logic processing to appropriate components (often JavaBeans or EJBs), manages session state, and selects the appropriate JSP view for rendering the response. This clear separation of concerns is a key advantage of MVC2.

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.