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 java
  1. A browser that uses a plug-in to process user data.

  2. A distributed application where the client program does not process datA. but instead passes data for processing to an enterprise bean running on an application server.

  3. An application that cannot be stopped by a firewall.

  4. An application compiled with the -thin option of the javac command

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

A thin-client application in J2EE context refers to a client program that doesn't process business logic itself but delegates it to enterprise beans on an application server. This reduces client-side complexity and centralizes business logic. Plug-ins, firewall bypassing, and compilation flags are unrelated to the thin-client architecture concept.

Multiple choice java
  1. Special icons for creating the user interface elements for thin clients.

  2. A data module saved to the component area of the database.

  3. A self-contained functional software unit that is assembled into a J2EE application and interfaces with other application components

  4. A JAR file

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

A J2EE component is a self-contained functional software unit that can be assembled into larger J2EE applications and interfaces with other components. Examples include servlets, EJBs, and JSP pages. It's not just UI elements, database modules, or a simple JAR file - components have specific interfaces and lifecycle management.

Multiple choice java
  1. Entity bean data survives crashes.

  2. An entity bean represents non-persistent data.

  3. It creates its own JAR file during deployment.

  4. You get authentication code without having to write any.

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

Entity beans represent persistent business data stored in a database, so their data survives system crashes and can be retrieved later. Session beans are non-persistent and only exist during a client session. Entity beans do not automatically create JAR files and authentication code must still be written by developers.

Multiple choice java
  1. When you want to be certain your application data persists between program invocations, even in the event of a crash.

  2. If you need to initiate a database transaction.

  3. To process transient data that can be re-created in the event of a crash.

  4. To keep people who do not know how to program from accidentally changing important logic code

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

Session beans are intended to perform tasks for a client and handle transient data. Unlike Entity beans (or JPA entities), they are not designed for long-term data persistence. If a crash occurs, the conversational state of a session bean is typically lost, making them ideal for transient business logic.

Multiple choice java
  1. To make the user interface more interesting.

  2. To simplify application deployment.

  3. To prevent malicious programs from gaining access to sensitive information on your database server.

  4. To make the application much easier to update, maintain, and manage.

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

The JSP-JavaBean separation follows the Model-View-Controller pattern. JSP handles presentation (the View), while JavaBeans encapsulate business logic and data (the Model). This separation means you can modify the user interface without touching business logic, and vice versa, making the application easier to update and maintain. Option A is incorrect because JSP is not about visual appeal but separation of concerns. Option C incorrectly suggests this prevents malicious programs - security requires separate measures. Option B is wrong - J2EE apps require deployment regardless of architecture.

Multiple choice java
  1. The thin client.

  2. Deployment descriptors.

  3. The JAR file.

  4. The bean's container

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

In container-managed persistence, the EJB container automatically handles all database operations - INSERT, UPDATE, DELETE, and SELECT. The container generates the SQL code and manages the connection pooling, transactions, and caching. The thin client (A) is the user interface, not involved in persistence. Deployment descriptors (B) configure behavior but don't execute data operations. The JAR file (C) is just packaging.

Multiple choice java
  1. When you implement entity or session bean methods to use SQL commands you provide.

  2. When the bean's container handles data storage and retrieval.

  3. When the J2EE server is never shut down

  4. When changes to database data are lost during a crash.

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

Bean-managed persistence means the developer explicitly writes database access code in the bean's implementation - typically using JDBC or JPA with SQL/JPAQL commands. You're responsible for connection management, transaction handling, and error recovery. Container-managed persistence (B) is the opposite - the container handles it. Options C and D are nonsensical distractors unrelated to persistence mechanisms.

Multiple choice java
  1. By thin clients.

  2. By calls to the database.

  3. By the J2EE server.

  4. By the bean's container.

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

Lifecycle methods (like @PostConstruct or ejbCreate) are managed and invoked by the EJB container (or the J2EE server environment) as it manages the bean's existence. Clients and databases do not trigger these internal transitions directly; the container ensures the bean is ready before client use.

Multiple choice java
  1. by using request.getMethod()

  2. by using request.setMethod()

  3. impossible to know

  4. none of these

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

To determine the HTTP method (GET or POST) used by a client request in JSP, you can use the request.getMethod() method.

The correct answer is:

The Answer is: A. by using request.getMethod()

Explanation:

A) by using request.getMethod(): This option is correct. The request.getMethod() method is used to retrieve the HTTP method used by the client request. It returns a string representing the HTTP method, such as "GET" or "POST".

B) by using request.setMethod(): This option is incorrect. The request.setMethod() method does not exist in JSP. There is no built-in method to set the HTTP method of a request.

C) impossible to know: This option is incorrect. It is possible to know the HTTP method used by the client request by using the request.getMethod() method.

D) none of these: This option is incorrect. The correct answer is option A, as explained above.

Therefore, the correct answer is:

The Answer is: A. by using request.getMethod()

Multiple choice java
  1. Stateless session beans doesn’t preserve any state across method calls

  2. Stateful session beans can be accesses by multiple users at the same time

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

Stateless session beans do not maintain any conversational state; every method call is independent, and the container can reuse instances for different clients. Stateful session beans, conversely, are dedicated to a single client for the duration of a session and cannot be accessed by multiple users simultaneously.

Multiple choice java
  1. null

  2. Primary Key class

  3. Home Object

  4. Remote Object

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

In EJB 2.x CMP, the container handles the actual creation of the record and the primary key. The ejbCreate method in a CMP bean is defined to return the primary key type, but the implementation must return null. The container then initializes the primary key and returns it to the client.

Multiple choice java
  1. The java command can access classes from more than one package, from a single JAR file.

  2. JAR files can be used with the java command but not with the javac command.

  3. In order for JAR files to be used by java, they MUST be placed in the /jre/lib/ext sub-directory within the J2SE directory tree.

  4. When a part of a directory tree that includes subdirectories with files is put into a JAR file, all of the files are saved in the JAR file, but the subdirectory structure is lost.

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

The java and javac commands can access classes from JAR files specified in the classpath. A single JAR file can contain classes from multiple packages. Option A is correct. Options B and C are incorrect (javac uses JARs, and they don't need to be in ext). Option D is incorrect (directory structure is preserved).

Multiple choice java
  1. must be created via a Java IDE.

  2. can run on different machines, but only with the same Operating System.

  3. are typically based on Servlets, JSPs and Enterprise Java Beans.

  4. need no runtime environment.

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

J2EE (Java 2 Enterprise Edition) applications are distributed, n-tier applications. They are typically composed of Servlets and JSPs for the web tier and Enterprise Java Beans (EJBs) for the business logic tier.

Multiple choice java
  1. transactional components.

  2. client side security and encryption.

  3. distributed object components.

  4. server-side components.

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

To solve this question, the user needs to have knowledge about the EJB (Enterprise JavaBeans) specification architecture.

The EJB specification architecture defines the structure and behavior of Enterprise JavaBeans, which are server-side components used to develop scalable and distributed enterprise applications.

Let's go through each option and explain why it is right or wrong:

A. transactional components: This option is incorrect. The EJB specification architecture does define transactional components. EJBs can participate in transactions, allowing for ACID (Atomicity, Consistency, Isolation, Durability) properties.

B. client-side security and encryption: This option is correct. The EJB specification architecture does not define client-side security and encryption. It primarily focuses on server-side components and does not specify how the client-side should handle security and encryption.

C. distributed object components: This option is incorrect. The EJB specification architecture does define distributed object components. EJBs are designed to be distributed across multiple servers and can be accessed remotely.

D. server-side components: This option is incorrect. The EJB specification architecture does define server-side components. EJBs are specifically designed to run on the server-side and provide services to client applications.

Therefore, the correct answer is:

The Answer is: B