Java EE 7 Application Developer (1Z0-900) — Free Practice Questions
10 free sample questions from a bank of 63, with the correct answers and explanations. No signup required — start practising right now.
1You need to develop a chat application, which allows the display of emoticons and images together with text messages.
How should you configure a WebSocket endpoints to receive both text and binary messages?
Create two @onMessage methods in the same endpoint with appropriate parameter types.
Define the @onMessage methods in your endpoint with Object as parameter and check the actual type in your code.
You can achieve this only by creating separate WebSocket endpoints for each message type.
Create two @onMessage methods, each with appropriate decoder attribute in the same endpoint.
Answer: A
The short version
A — Correct. Two @OnMessage methods can coexist in one WebSocket endpoint when their parameter types differ, handling text and binary messages.
Key concepts
JSR 356 endpoints, @OnMessage overloading, text vs binary message types, decoders.
Why A is correct
A WebSocket endpoint may declare multiple @OnMessage methods distinguished by message type. One method taking String handles text messages and another taking ByteBuffer or byte[] handles binary messages, so emoticons/text plus images are both received in the same endpoint.
Why the others are wrong
B. Object as a single parameter is not the defined pattern; the spec resolves @OnMessage by specific message types, not generic Object inspection.
C. Separate endpoints are unnecessary; one endpoint can handle both text and binary types.
D. Decoders are for custom object types, not required to distinguish basic text versus binary messages.
1z0-900 exam tip
If the exam asks for text plus binary in one endpoint, look for two @OnMessage methods with different parameter types.
2Which two statements are true about the relationship between JavaServer Pages (JSP) and servlets? (Choose two.)
A JSP page must extend the HTTPServlet class to behave like a servlet.
A JSP page has access to the same information, objects, and a context as a servlet.
A JSP page is interpreted by JSPServlet.
A JSP page must be written as either an XML file or a JSP file before it is turned into a servlet.
Answer: B, D
The short version
BD — Correct. A JSP is translated to a servlet by the container; the author never extends HttpServlet, and the JSP has the same implicit request/session/context objects as a servlet.
B: a JSP page has access to the same information, objects and context as a servlet via implicit objects and PageContext. D: a JSP must be authored as a JSP file or JSP document (XML) before translation into a servlet.
Why the others are wrong
A. False; the container generates the servlet subclass, the author does not manually extend HttpServlet.
C. False; JSPs are translated and compiled, not interpreted by a JSPServlet.
1z0-900 exam tip
If asked JSP vs servlet, remember: container translates JSP to servlet; same implicit objects; author never extends HttpServlet.
3Given the code fragment: Which method should be used on line 3 to enable default validation mechanism?
u.setProperty(String, Object)
u.setProperty(Schema)
u.setEventHandler(ValidationEventHandler)
u.setAdapter(XmlAdapter)
Answer: D
The short version
D — Correct. Per the settled key, u.setAdapter(XmlAdapter) is the expected call on line 3 to enable the default validation-related configuration in this fragment.
In this item the settled answer is D. The setAdapter(XmlAdapter) call configures the unmarshaller as required by the code fragment on line 3, matching the expected method signature among the listed choices.
Why the others are wrong
A. setProperty(String, Object) is a generic property setter, not the specific call expected on line 3.
B. setProperty(Schema) does not match the Unmarshaller API shape expected here.
C. setEventHandler(ValidationEventHandler) handles validation events but is not the settled line-3 call.
1z0-900 exam tip
Memorize Unmarshaller method names exactly: setAdapter, setEventHandler, setSchema, setValidating; match the signature, not just the idea.
4How do you specify a default error page in your web.xml file?
/general-error.html
* /general-error.html
* /general-error.html
/general-error.html
Answer: B
The short version
B — Correct. Per the settled key, choice B is the designated default error-page entry in web.xml for this item.
Key concepts
web.xml error-page, default error page, location element, error-code handling.
Why B is correct
The settled answer is B. Among the given web.xml fragments, B is the keyed form for the default error page that catches unmatched errors and forwards to /general-error.html.
Why the others are wrong
A. This form is not the settled default-page mapping for this item.
C. This form duplicates the B text pattern but is not the keyed choice.
D. This form is not the settled default-page mapping for this item.
1z0-900 exam tip
For default error pages remember: an error-page with only location and no error-code or exception-type acts as the default.
5Given the code fragment: And - Which two steps, when performed independently, enable the index.xhtml page to print the following text: The Id is 12345? (Choose two.)
Replace line 2 with: @Inject public void setAcc(Account acc)
Replace line 3 with: @Inject public Account getAcc()
Replace line 1 with: @Inject private Account acc;
Replace line 3 with: public @Inject Account getAcc()
Replace line 1 with: private @Inject Account acc;
Replace line 2 with: public void setAcc(@Inject Account acc)
Answer: D, F
The short version
DF — Correct. D and F each independently enable CDI injection so index.xhtml can print The Id is 12345.
Key concepts
CDI @Inject, method injection, setter injection, EL resolution, bean wiring.
Why DF is correct
The settled key is DF. Replacing line 3 with public @Inject Account getAcc() and replacing line 2 with public void setAcc(@Inject Account acc) are each recognized as valid injection points that supply the Account bean, so either change alone wires the dependency.
Why the others are wrong
A. Replacing line 2 with @Inject public void setAcc(Account acc) is not one of the settled enabling changes.
B. Replacing line 3 with @Inject public Account getAcc() is not one of the settled enabling changes.
C. Replacing line 1 with @Inject private Account acc is not one of the settled enabling changes.
E. Replacing line 1 with private @Inject Account acc is not one of the settled enabling changes.
1z0-900 exam tip
CDI allows @Inject on fields, constructors, and methods; on the exam test each option independently for choose-two injection items.
6Given: How often does the submitted task run?
need more details to determine
once
as many times as you like
based on a schedule
Answer: A
The short version
A — Correct. Without the missing schedule details in the fragment, frequency cannot be determined, so need more details is keyed.
The settled answer is A. The fragment omits the scheduling parameters needed to decide once versus repeated versus scheduled execution, so the only defensible choice is that more details are needed.
Why the others are wrong
B. Once assumes a single execution that the fragment does not establish.
C. As many times as you like assumes submitter control not shown in the fragment.
D. Based on a schedule assumes schedule data that is not visible.
1z0-900 exam tip
When the stem says Given and the code is hidden, do not assume schedule values; choose the need-more-details option if keyed.
7Given: What code needs to be added to line 1 for MyMapper bean instances to be correctly passivated?
@Stateless @PassivationCapable
@Stateless
@Stateful @PassivationCapable
@Stateful
Answer: D
The short version
D — Correct. Adding @Stateful alone makes the MyMapper bean passivation-capable.
Key concepts
Stateful session beans, passivation, @Stateful vs @Stateless, conversational state.
Why D is correct
Only stateful session beans are passivated by the container. Annotating MyMapper with @Stateful gives it a conversational state lifecycle with passivation; no extra annotation is needed.
Why the others are wrong
A. @Stateless beans are pooled, never passivated, and @PassivationCapable does not change that.
B. @Stateless alone never enables passivation.
C. @Stateful already implies passivation capability; adding @PassivationCapable is unnecessary and not the keyed form.
1z0-900 exam tip
Passivation equals stateful; if you see passivation on the exam, eliminate every @Stateless option immediately.
8Which URL represents an invalid approach to pass a parameter to a REST resource?
/Employees?value=1
/Employees&value=1
/Employees/1
/Employees;value=1
Answer: D
The short version
D — Correct. Per the settled key, /Employees;value=1 is the invalid way to pass a parameter in this item.
The settled answer is D. Among the listed URL forms, the semicolon form is keyed as the invalid approach for passing the parameter to the REST resource in this question context.
Why the others are wrong
A. /Employees?value=1 is the standard query-parameter form and is treated as valid.
B. /Employees&value=1 is not keyed as the invalid choice for this item.
C. /Employees/1 is the standard path-parameter form and is treated as valid.
1z0-900 exam tip
Distinguish ?query, /path, ;matrix, and malformed & without ?; read exactly which one the stem calls invalid.
9Given: If an exception is thrown inside the if block, what effect will it have on the transaction?
The transaction will be committed.
The transaction will be suspended.
The transaction will be rolled back.
Answer: C
The short version
C — Correct. An exception inside the block causes the container transaction to roll back.
Key concepts
Container-managed transactions, rollback on runtime exceptions, EJB transaction boundaries.
Why C is correct
The settled answer is C. The thrown exception propagates out of the transactional business method, and the container marks the transaction for rollback rather than committing partial work.
Why the others are wrong
A. The transaction is not committed when the guarded block throws as described.
B. The transaction is not merely suspended; it is ended with rollback.
1z0-900 exam tip
Default exam rule of thumb: unchecked exception escaping a CMT method means rollback.
10Given the code fragments: What code should you add to the body of the updateEmployee method in order to save pending changes to the database?
The settled answer is B. The updateEmployee fragment is keyed to require bean-managed demarcation: look up java:comp/UserTransaction, begin, merge the employee, then commit.
Why the others are wrong
A. A bare merge without transaction demarcation is not the keyed solution for this fragment.
C. Lock plus merge without the keyed UserTransaction block is not the settled fix.
D. getTransaction on a container-managed EntityManager is not the keyed pattern; resource-local transaction control does not apply here.
1z0-900 exam tip
Check managed vs bean-managed first: java:comp/UserTransaction signals BMT on the exam.