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 web technology
  1. HttpSession.setMinInactiveInterval(10);

  2. HttpSession.setMinInactiveInterval(10 * 60);

  3. HttpSession.setMaxInactiveInterval(10 * 60);

  4. HttpSession.setMaxInactiveInterval(10);

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

The setMaxInactiveInterval method accepts seconds as the parameter, not minutes. To set 10 minutes, you need to convert to seconds (10 * 60 = 600). Options A and B use setMinInactiveInterval which doesn't exist. Option D only sets 10 seconds, not 10 minutes.

Multiple choice technology web technology
  1. HttpServletRequest.getWriter();

  2. HttpServlerResponse.getCharacterWriter();

  3. HttpServetRequest.getOutputStream()

  4. HttpServletResonse.getWriter();

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

HttpServletResponse.getWriter() returns a PrintWriter object that can send character data (text) to the client. Option A is HttpServletRequest (request, not response). Option B has a typo (HttpServlerResponse) and getCharacterWriter doesn't exist. Option C is request (not response) and returns OutputStream for binary data.

Multiple choice technology web technology
  1. getAttributeNames()

  2. getAllAttributes()

  3. It is not possible to retrieve all the attributes in one call.

  4. getAttributes()

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

ServletContext.getAttributeNames() returns an Enumeration of all attribute names stored in the servlet context. Options B and D (getAllAttributes, getAttributes) are not valid methods. Option C is incorrect - you CAN retrieve all attribute names in one call.

Multiple choice technology web technology
  1. An IllegalStateException exception will be thrown because of the presence of

  2. A second call to setAttribute() with the same attribute name will just replace the

  3. The behavior is not defined in the Servlet Specification.

  4. None of the above.

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

To answer this question, the user needs to know about the HttpSession and its setAttribute() method.

Option A: This option is incorrect. IllegalStateException is thrown when we try to set an attribute on an already invalidated session, not when we set an attribute with the same name.

Option B: This option is correct. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.

Option C: This option is incorrect. The Servlet Specification does define the behavior of HttpSession.setAttribute() method when it is called the second time with the same attribute name.

Option D: This option is incorrect as option B is the correct answer.

Therefore, the correct answer is:

The Answer is: B. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.

Multiple choice technology platforms and products
  1. Client

  2. Bindings

  3. No default. The transport has to be defined explicitly

  4. None of the above

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

When defining a JNDI connection factory for IBM WebSphere MQ, the default transport type is 'Bindings' mode. This provides direct in-memory communication when client and queue manager are on the same machine. 'Client' transport (TCP/IP) must be explicitly specified for remote connections.

Multiple choice technology web technology
  1. init()

  2. service()

  3. getServletContext()

  4. getServletConfig()

  5. getServletInfo()

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

The Servlet interface has 5 methods: lifecycle methods (init, service, destroy) and ancillary methods (getServletConfig, getServletInfo). The question asks for ancillary methods - those NOT part of the core lifecycle. getServletConfig() returns the servlet's configuration object, and getServletInfo() returns descriptive information about the servlet. These are considered ancillary/support methods. Options A and B are lifecycle methods. Option C (getServletContext) returns the context but is NOT a method of Servlet interface - it's a method of ServletConfig interface (accessed via getServletConfig().getServletContext()).

Multiple choice technology web technology
  1. The service() method is the heart of the servlet.

  2. Each request message from a client results in a single call to the servlet's service() method

  3. The service() method reads the request and produces the response message from its parameters

  4. The service() method is called to allow your servlet to clean up any resources before the servlet is unloaded.

  5. The InputStream from the client can be obtained via the getInputStream() method

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

The service() method is indeed the core of a servlet - every client request triggers a single call to service(), which reads the HttpServletRequest and produces the HttpServletResponse. The InputStream from the client can be obtained via request.getInputStream(). Option D describes the destroy() method, not service().

Multiple choice technology web technology
  1. Servlets are used to process the client request

  2. Servlets enables rapid development of mission-critical application that are versatile, reusable and portable across middleware while protecting IT investment

  3. A Servlet can handle multiple request concurrently and be used to develop high performance system

  4. A Servlet can be used to load balance among serveral servers, as Servlet can easily forward request

  5. With the help of servlet we can achieve Clustering

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

Servlets process client requests (A), handle multiple concurrent requests for high performance (C), and can forward requests to enable load balancing (D). Option B is incorrect because it describes EJBs, not servlets. Option E is incorrect - clustering is achieved at the application server level, not by servlets themselves.

Multiple choice technology web technology
  1. Run on Java enabled web browser

  2. Serverside Applet

  3. Platform independent

  4. Multithread processing

  5. Session information is maintainable with servlets

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

Servlets are server-side components that run in a web container, NOT in a browser (A is false). They are platform-independent Java programs (C), support multithreaded request processing (D), and can maintain session information via HttpSession (E). The term 'Serverside Applet' is accurate (B).

Multiple choice technology web technology
  1. start();

  2. service();

  3. init();

  4. destroys();

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

The Java Applet lifecycle has standard methods: init(), start(), stop(), paint(), and destroy(). The option 'destroys()' is incorrect because the actual method is 'destroy()' (not 'destroys()'), making it the option that is NOT a phase of the applet lifecycle.

Multiple choice technology web technology
  1. a. FilePathXmlApplicationContext class

  2. b. SystemXmlPathApplicationContext class

  3. c. FileSystemXmlApplicationContext class

  4. d. XmlFileApplicationContext class

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

FileSystemXmlApplicationContext is a concrete implementation of ApplicationContext that loads bean definitions from an XML file in the file system. This is different from ClassPathXmlApplicationContext which loads from the classpath.

Multiple choice technology web technology
  1. a. Through TransactionFactory interface

  2. b. Through TransactionOperations interface

  3. c. Through TransactionCallback interface

  4. d. Through PlatformTransactionManager interface

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

PlatformTransactionManager is Spring's strategy interface for abstracting transaction management across different environments (JDBC, JTA, Hibernate, JPA). It decouples application code from specific transaction implementations.