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. SessionFactory.getSession();

  2. SessionFactory.openSession();

  3. SessionFactory.get();

  4. (session)SessionFactory.getObject();

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

To obtain a Session object from SessionFactory, you call the openSession() method. The Session interface is the primary interface for Hibernate persistence operations, used for CRUD operations and queries.

Multiple choice technology web technology
  1. <hibernate-mapping>

  2. <session-mapping>

  3. <sessionfactory-mapping>

  4. none of the above

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

The root-level element in a Hibernate mapping file is . This element serves as the container for all class and collection mappings. It can include attributes like package, schema, and catalog to apply defaults to nested mappings.

Multiple choice technology web technology
  1. lazy=false;

  2. lazy=true;

  3. lazy=yes;

  4. lazy=no;

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

Hibernate uses lazy loading by default with lazy=true. This means associations and collections are not loaded from the database until they are actually accessed in code, which improves performance by avoiding unnecessary queries.

Multiple choice technology web technology
  1. An open source, interactive Web content generation system similar to Adobe Flash

  2. A server-side programming language that enables rich Internet applications

  3. A programming technique that allows portions of Web pages to be updated without a full refresh

  4. The next generation of the JavaScript programming language

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

AJAX (Asynchronous JavaScript and XML) is a technique that allows web applications to send and retrieve data from a server asynchronously, without interfering with the display and behavior of the existing page. This enables dynamic updates to portions of a webpage without requiring a full page refresh.

Multiple choice technology web technology
  1. Protocol for accessing a Web Service

  2. SOAP is designed to communicate via Internet

  3. SOAP allows you to get around firewalls

  4. 1 & 3

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

SOAP (Simple Object Access Protocol) is indeed a protocol for accessing web services (A), designed for internet communication (B), and uses HTTP which allows it to traverse firewalls (C). All three statements correctly describe SOAP's purpose and characteristics.

Multiple choice technology programming languages
  1. GET

  2. TRACE

  3. POST

  4. HEAD

  5. OPTIONS

  6. SERVICE

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

HTTP methods are idempotent if multiple identical requests have the same effect as a single request. GET, HEAD, OPTIONS, TRACE, and PUT are idempotent. POST is NOT idempotent - submitting the same POST request multiple times can create multiple resources or change state multiple times (e.g., placing an order twice).

Multiple choice technology programming languages
  1. If the servlet has a doGet() method, it executes that instead.

  2. 404 response code: SC_NOT_FOUND.

  3. 405 response code: SC_METHOD_NOT_ALLOWED.

  4. 500 response code: SC_INTERNAL_SERVER_ERROR.

  5. 501 response code: SC_NOT_IMPLEMENTED.

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

If a servlet receives an HTTP POST request but does not implement the doPost() method, the default implementation in HttpServlet returns an HTTP 405 (Method Not Allowed) response code, indicating that the requested HTTP method is not supported by this resource.

Multiple choice technology programming languages
  1. 2

  2. 3

  3. 4

  4. 5

  5. 6

  6. 7

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

This HTML form has a multi-select dropdown with 6 options, 2 of which (Java and C) are pre-selected with the 'selected' attribute. When the user clicks submit without changing selections, the servlet receives: Languages=JAVA, Languages=C, and button= - totaling 3 parameter name-value pairs. However, with 'multiple' select, each selected value creates a separate parameter with the same name. If all 6 were selected, it would be 6 Languages parameters plus 1 button parameter = 7 total.

Multiple choice technology programming languages
  1. During web application startup

  2. If there are insufficient instances of the servlet to service incoming requests

  3. On a client first requesting the servlet

  4. At the same time as a different servlet is instantiated, when that different servlet makes use of the servlet in question

  5. After the time specified on an UnavailableException has expired

  6. At some arbitrary point in the web application or application server lifetime

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

Servlets are instantiated during web application startup when configured with load-on-startup (A). They are also created on the first client request to that servlet if not already initialized (lazy initialization). After an UnavailableException expires, the servlet becomes available and may be instantiated (E). Option F, while vaguely worded, reflects that containers manage servlet lifecycle dynamically - they can create instances based on demand, configuration, or internal optimization at various points in the application lifetime. Option B is incorrect because containers manage instance pooling automatically, not by creating new ones on demand. Option D is incorrect because servlet instantiation is not triggered by other servlets being instantiated.

Multiple choice technology web technology
  1. Hibernate does not support lazy initialization for detached objects.

  2. Access to a lazy association outside of the context of an open Hibernate session will result in an exception.

  3. Lazy fetching is way to avoid unnecessary column reads.

  4. All the above.

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

All statements are true: Hibernate cannot lazily initialize associations on detached objects; accessing a lazy association outside an open session throws a LazyInitializationException; and lazy fetching avoids unnecessary database reads.

Multiple choice technology web technology
  1. Pass an instance of java.util.Properties to Configuration.setProperties().

  2. Place hibernate.properties in a root directory of the classpath.

  3. Set System properties using java -Dproperty=value.

  4. All the above

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

Hibernate configuration can be passed in multiple ways: programmatically via Configuration.setProperties() with a Properties object, declaratively via hibernate.properties file in the classpath root, or as JVM system properties using -D flags. All three approaches are valid.