Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free Oracle Java EE 7 Application Developer 1Z0-900 Exam Questions

Last updated: · 12 practice questions with answers and explanations

Page: 1 / 15 Total 142 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Understand Java EE Architecture

Skill tested: Selects Java EE component scopes and injection mechanisms for web and business tiers.

A Java EE 7 application has a JSF web tier and a service layer packaged in an EAR. Several request-handling components need a shared service object that can participate in container-managed transactions, while request-specific presentation state must not leak between users. The team wants type-safe injection rather than looking up the service by a string name, and it wants the container to manage the service instance lifecycle. Which design best meets these requirements?

Correct Answer: B. Implement the service as a stateless session bean and inject it into the web components; keep presentation state in request-scoped CDI beans.
Explanation:

A stateless session bean is a container-managed business component with EJB services, including container-managed transactions, and can be injected by type into Java EE components. Request-scoped CDI beans provide isolated state for each request. An application-scoped CDI bean does not by itself provide the EJB transaction semantics requested, and storing per-user state there risks sharing it across users. A servlet is a web component, not an appropriate business-service substitute, while a stateful bean instance is not safely shared through a static field.

Question 2

New Multiple answers

Topic: Manage Persistence using JPA Entities and BeanValidation

Skill tested: Maps bidirectional JPA relationships and maintains consistent in-memory association state.

A purchasing application models `PurchaseOrder` and `OrderLine` as a one-to-many relationship. Each line belongs to exactly one order, and the database uses a foreign key in the order-line table. The team wants changes made through either entity's object references to be reflected correctly when the persistence context is flushed. `PurchaseOrder` is designated as the owning side in the existing mapping, and cascading persistence from an order to its new lines is required. Which two implementation choices satisfy the requirements? Select TWO.

Correct Answer: B. Map `PurchaseOrder.lines` with `@OneToMany(cascade = CascadeType.PERSIST)` and `@JoinColumn` for the foreign key.; E. In the order's add-line method, add the line to `lines` and set `line.order` to the order.
Explanation:

Because the scenario explicitly makes `PurchaseOrder` the owning side, its one-to-many mapping must define the foreign-key mapping, here with `@JoinColumn`; `CascadeType.PERSIST` propagates persistence to newly added lines. Both sides of a bidirectional association should also be updated in application code so the in-memory graph agrees with the owning-side state. `mappedBy` would make the order inverse, contradicting the stated mapping. `ManyToOne` does not use `mappedBy` on the owning side, and `CascadeType.REMOVE` does not propagate persist operations.

Question 3

New Single answer

Topic: Implement Business Logic by Using EJBs

Skill tested: Chooses EJB transaction attributes that preserve caller transaction boundaries.

An order-processing service is invoked from several EJB methods that each begin a container-managed transaction. One caller records an order and then invokes the service to update a delivery estimate. That update should participate in the caller's transaction when one exists, but it must also work when invoked by a scheduled process with no transaction. A failure in the estimate update must roll back any transaction in which it participates. Which transaction attribute should the estimate method use?

Correct Answer: A. `REQUIRED`, because it joins an existing transaction or starts one when needed.
Explanation:

With container-managed transactions, `REQUIRED` uses the caller's transaction when one is present and starts a new transaction when the caller has none. Consequently, the update can participate in the order transaction and can also run from the scheduled process. A system exception or an application exception configured for rollback can cause the participating transaction to roll back. `MANDATORY` would reject the transactionless call; `NEVER` forbids a transaction; and `NOT_SUPPORTED` suspends an existing transaction, violating the required atomicity.

Question 4

New Multiple answers

Topic: Use Java Message Service API

Skill tested: Configures message-driven bean acknowledgement and transaction behavior for reliable processing.

A fulfillment system receives persistent JMS messages from a queue through a message-driven bean. Processing includes a database update, and the organization requires the message consumption and database work to commit together so that a processing failure does not acknowledge a message whose database update rolled back. The bean uses container-managed transactions, and the JMS provider supports the required transactional integration. Which two choices best support this requirement? Select TWO.

Correct Answer: A. Use a container-managed transaction for the message-driven bean's `onMessage` invocation and let the container control acknowledgement.; E. Configure the message-driven bean to use `REQUIRED` transaction semantics for message processing.
Explanation:

For a message-driven bean using container-managed transactions, the message delivery is processed in a transaction controlled by the container; `REQUIRED` is the standard transaction attribute and ensures a transaction exists for the invocation. With transactional integration, the JMS work and database update can commit or roll back together. `NOT_SUPPORTED` removes that transactional boundary. A nontransacted session with early acknowledgement risks losing a message after a database failure, and returning normally after swallowing an exception can cause the transaction to commit rather than trigger redelivery.

Question 5

New Single answer

Topic: Implement SOAP Services by Using JAX-WS and JAXB APIs

Skill tested: Uses JAXB annotations to control XML element names and Java-to-schema mappings.

A SOAP integration must expose a Java DTO whose XML representation conforms to a partner's schema. The schema requires a root element named `shipment`, a child element named `tracking-code`, and an optional `estimated-arrival` element. The Java class uses camel-case field names, and the team wants JAXB to serialize and deserialize the object without writing custom marshalling code. Which approach is most appropriate?

Correct Answer: A. Annotate the class with `@XmlRootElement(name="shipment")`, map the tracking property with `@XmlElement(name="tracking-code")`, and make the arrival property optional in the JAXB mapping.
Explanation:

JAXB annotations define the Java-to-XML mapping. `@XmlRootElement` supplies the document root element name, while `@XmlElement` can explicitly name a property element and express optionality through its mapping settings. This avoids relying on defaults that may not match the partner schema. `@WebService` configures a JAX-WS endpoint rather than renaming JAXB fields. With `XmlAccessType.NONE`, unannotated properties are not bound, and `@XmlType` does not replace `@XmlRootElement` as the root-element declaration.

Question 6

New Single answer

Topic: Create Java Web Applications using Servlets

Skill tested: Applies servlet request dispatch and filter ordering to enforce request policies.

A Java EE 7 application accepts requests under `/reports/*`. Before any report servlet handles a request, the application must reject requests lacking a required custom header and record an audit entry. The policy applies to all HTTP methods and must not be duplicated across servlet classes. A developer proposes checking the header only in each servlet's `doGet` method. What is the best implementation?

Correct Answer: B. Create a `Filter` mapped to `/reports/*`, perform the header check and audit in `doFilter`, and invoke the chain only when the request is accepted.
Explanation:

A servlet filter can be mapped to a URL pattern, inspect HTTP request headers, perform cross-cutting work, and decide whether to continue the filter chain. This applies consistently before the mapped servlet handles any supported HTTP method. A request listener observes request lifecycle events but is not the appropriate mechanism for blocking dispatch through the filter chain. A session listener runs at session lifecycle events, not on every request. Checking only `doGet` misses other methods and duplicates policy across servlets.

Question 7

New Single answer

Topic: Create Java Web Applications using JSPs

Skill tested: Uses JSP error-page directives and exception handling to provide controlled error responses.

A JSP-based application must show a friendly error page when an uncaught exception occurs during JSP processing, while preserving access to the exception details for server-side diagnostics. The team does not want to expose stack traces to users or add repeated `try`/`catch` blocks throughout the page. Which configuration best meets the requirement?

Correct Answer: D. Declare an error page with the JSP `errorPage` directive on the source JSP, and mark the target JSP with `isErrorPage="true"`.
Explanation:

A source JSP can designate an error page with the `errorPage` directive. The target page uses `isErrorPage="true"` to make the implicit `exception` object available for controlled handling. The error page can log or otherwise handle details without rendering a stack trace to the user. Marking ordinary pages as error pages does not establish error dispatch, and displaying exception details risks information disclosure. An include is static composition, not exception handling, and `autoFlush` controls buffering rather than error-page routing.

Question 8

New Single answer

Topic: Implement REST Services using JAX-RS API

Skill tested: Designs JAX-RS resource methods with correct HTTP semantics and response statuses.

A JAX-RS resource manages customer records at `/customers/{id}`. A client submits a complete replacement representation for an existing customer and expects the server to replace that resource rather than create a separate subordinate resource. The service should return no response body after a successful update. The resource already has a method that loads and validates the customer. Which method design best expresses the required REST behavior?

Correct Answer: D. A `@PUT` method on `/customers/{id}` that accepts the representation and returns a response with status 204 after successful replacement.
Explanation:

`PUT` is the appropriate HTTP method for replacing the state of the resource identified by the URI. A successful update with no response entity can be represented by HTTP 204 No Content. `POST` is not the clearest expression of replacement at a known resource URI and status 201 indicates creation. `GET` is intended for retrieval and should not perform replacement; query parameters are also unsuitable for the full representation. Delete-and-recreate introduces unnecessary operations and failure windows.

Question 9

New Single answer

Topic: Create Java Applications using WebSockets

Skill tested: Implements WebSocket endpoint callbacks and message handling for connection lifecycle events.

A monitoring dashboard uses a Java EE 7 WebSocket endpoint to maintain live browser connections. The server must register a client when its connection opens, process each complete text message, and remove the client when the connection closes. The endpoint must use the standard JSR 356 server programming model and avoid polling from the browser. Which implementation approach is appropriate?

Correct Answer: A. Create a class annotated with `@ServerEndpoint`, with `@OnOpen`, `@OnMessage`, and `@OnClose` methods for the respective lifecycle events.
Explanation:

JSR 356 server endpoints are declared with `@ServerEndpoint`. The container invokes `@OnOpen` when a WebSocket connection is established, `@OnMessage` for incoming messages, and `@OnClose` when the connection closes. This matches the required event-driven lifecycle without browser polling. A servlet and HTTP filter do not receive WebSocket frames through these annotations. CDI observer methods are not WebSocket lifecycle callbacks, and repeated REST requests are polling rather than a persistent WebSocket connection.

Question 10

New Single answer

Topic: Develop Web Applications using JSFs

Skill tested: Applies JSF lifecycle behavior to validation failures and model update decisions.

A JSF 2 application uses a form with a required input and a command button. During a submission, conversion succeeds for one field but validation fails for another. The developer observes that the action method does not run and the model bean retains its previous values. The product owner wants the application to display the validation messages and avoid executing business logic on invalid input. Which explanation best describes the expected JSF behavior?

Correct Answer: B. Validation failure causes JSF to skip normal model update and application invocation for that request and render the response with messages.
Explanation:

When conversion or validation fails during Process Validations, JSF marks the request as a validation failure and proceeds to render the response with queued messages rather than performing the normal Update Model Values and Invoke Application phases. Thus, the bean retains its prior model values and the action method is not invoked, preventing business logic from running on invalid input. JSF does not rely on a transaction rollback for this behavior, call the action with nulls, or remove components from the tree.

Question 11

New Multiple answers

Topic: Secure Java EE 7 Applications

Skill tested: Combines web security constraints and role mapping to protect administrative resources.

A Java EE web application contains `/admin/*` resources that only authenticated users assigned the application role `Administrator` may access. The application must use container-managed authentication and must deny access to unauthenticated users rather than serve the protected content. Deployment environments map enterprise identities to application roles. Which two configuration choices implement this declarative access control? Select TWO.

Correct Answer: D. Declare the `Administrator` security role and configure the deployment's role mapping to associate authorized identities with it.; E. Declare a security constraint covering `/admin/*` with an authorization constraint naming the `Administrator` role.
Explanation:

A declarative security constraint associates the `/admin/*` URL pattern with an authorization constraint requiring the `Administrator` role. The application must also declare the role and the deployment must map identities or groups to that application role. Together, these settings let the container enforce authentication and authorization before serving protected resources. A role reference can map component-local role names but does not authenticate users. JSP scriptlets and client-supplied headers are not container-managed authorization controls, and an unrestricted resource defeats the requirement.

Question 12

New Single answer

Topic: Use CDI Beans

Skill tested: Uses CDI qualifiers to resolve ambiguous injection points for implementations of one interface.

A Java EE application has two CDI beans that implement `PaymentGateway`: one sends transactions to a production processor and one routes them to a simulator. Both are discoverable and have the same bean type. A production checkout bean must receive only the production implementation, while the simulator remains injectable into test-support components. The team wants compile-time-visible injection metadata, not string-based lookup or deployment profiles that remove a bean. What should the team do?

Correct Answer: A. Define a CDI qualifier for the production gateway, annotate that implementation with it, and use the qualifier at the checkout injection point.
Explanation:

A CDI qualifier distinguishes beans that share an assignable type. Applying a production qualifier to the production implementation and the matching qualifier at the checkout injection point gives deterministic, type-safe resolution while leaving the simulator available for other consumers. `@Alternative` requires deliberate enablement and enabling both does not resolve ambiguity. A scope annotation affects lifecycle, not bean selection. Iterating over `Instance` and taking the first result makes selection dependent on ordering rather than expressing the required semantic choice.