Oracle Certification

1Z0-1095 — Java Enterprise Study Guide

58 practice questions with correct answers and detailed explanations. Use this guide to review concepts before taking the practice exam.

▶ Take Practice Exam 58 questions  ·  Free  ·  No registration

About the 1Z0-1095 Exam

The Oracle Java Enterprise (1Z0-1095) certification validates professional expertise in Oracle technologies. This study guide covers all 58 practice questions from our 1Z0-1095 practice test, complete with correct answers and explanations to help you understand each concept thoroughly.

Review each question and explanation below, then test yourself with the full interactive practice exam to measure your readiness.

58 Practice Questions & Answers

Q1 Easy

Which Jakarta EE specification defines the programming model for building RESTful web services?

  • A Jakarta Servlet
  • B Jakarta REST ✓ Correct
  • C Jakarta WebSocket
  • D Jakarta Messaging
Explanation

Jakarta REST (formerly JAX-RS) provides annotations and APIs for building RESTful web services in Jakarta EE applications.

Q2 Easy

In Jakarta Persistence, which annotation is used to mark a class as a managed entity?

  • A @Entity ✓ Correct
  • B @Persistent
  • C @Table
  • D @Column
Explanation

@Entity marks a class as a persistent entity that will be mapped to a database table by the JPA provider.

Q3 Medium

Which of the following best describes the purpose of the EntityManager in Jakarta Persistence?

  • A To configure database connection pooling and optimize query performance across multiple threads
  • B To validate entity constraints and enforce referential integrity at the application layer
  • C To cache compiled SQL statements and manage transaction logs
  • D To manage the lifecycle of entity instances and their persistence context within a particular session ✓ Correct
Explanation

The EntityManager is the primary interface for managing entity instances and coordinating their lifecycle with the database within a persistence context.

Q4 Medium

What is the default fetch strategy for a @OneToMany relationship in Jakarta Persistence?

  • A IMMEDIATE
  • B LAZY ✓ Correct
  • C EAGER
  • D EXPLICIT
Explanation

The default fetch strategy for @OneToMany relationships is LAZY, meaning the related collection is loaded only when explicitly accessed.

Q5 Easy

Which Jakarta Contexts and Dependency Injection scope annotation indicates that a bean instance is created once per application lifetime?

  • A @SessionScoped
  • B @ConversationScoped
  • C @RequestScoped
  • D @ApplicationScoped ✓ Correct
Explanation

@ApplicationScoped creates a single bean instance that exists for the entire duration of the application and is shared across all users and sessions.

Q6 Medium

In Jakarta Enterprise Beans, which of the following accurately describes the relationship between a stateful session bean and its conversational state?

  • A Conversational state is shared among all clients accessing the same stateful session bean instance
  • B Conversational state can only be stored in instance variables that are explicitly marked as Serializable
  • C Conversational state is maintained per client for the duration of the session and lost when the client is no longer referenced ✓ Correct
  • D Conversational state is automatically serialized to disk after each method invocation to ensure durability
Explanation

Stateful session beans maintain conversational state in instance variables per client session and this state is preserved across method calls until the client reference is removed or the session times out.

Q7 Medium

Which transaction attribute in Jakarta Enterprise Beans specifies that a method must always run within a transaction, creating a new one if necessary?

  • A REQUIRES_NEW
  • B MANDATORY
  • C REQUIRED ✓ Correct
  • D SUPPORTS
Explanation

REQUIRED (the default) ensures the method executes within a transaction, either using an existing one or creating a new transaction if none exists.

Q8 Easy

In Jakarta RESTful Web Services, which annotation is used to bind a method parameter to a query string parameter in the URL?

  • A @HeaderParam
  • B @PathParam
  • C @FormParam
  • D @QueryParam ✓ Correct
Explanation

@QueryParam binds method parameters to query string parameters passed in the request URL (e.g., ?param=value).

Q9 Hard

Which of the following scenarios would require the use of @PersistenceContext(type=PersistenceContextType.EXTENDED) in a Jakarta EE application?

  • A When a stateful session bean must maintain its persistence context across multiple client method invocations ✓ Correct
  • B When you want to configure connection pooling and database optimization settings
  • C When you need to ensure that all queries execute with pessimistic locking for data consistency
  • D When you need to run queries in read-only mode to prevent accidental data modifications
Explanation

EXTENDED persistence context type keeps the persistence context alive for the entire lifecycle of a stateful session bean, allowing entities to remain managed across multiple method calls.

Q10 Easy

In Jakarta Batch, which component is responsible for reading items from a data source?

  • A Batchlet
  • B ItemReader ✓ Correct
  • C ItemWriter
  • D JobListener
Explanation

An ItemReader is the batch component that reads data from a source, which is then processed and written by an ItemWriter.

Q11 Medium

Which Jakarta Messaging API interface represents a connection to a message broker that manages message destinations?

  • A Connection ✓ Correct
  • B Session
  • C Message
  • D MessageProducer
Explanation

A Connection in Jakarta Messaging represents a client connection to the message broker and is used to create sessions for sending and receiving messages.

Q12 Medium

In Jakarta Bean Validation, which annotation validates that a string value matches a regular expression pattern?

  • A @Regex
  • B @Length
  • C @Size
  • D @Pattern ✓ Correct
Explanation

@Pattern is used to validate that a string matches the specified regular expression pattern using the regex attribute.

Q13 Hard

Which of the following statements best explains the role of a persistence unit in Jakarta Persistence?

  • A A persistence unit is a single EntityManager instance that manages a specific set of entity classes and their mappings to a particular database
  • B A persistence unit is a cache that stores compiled SQL queries for performance optimization across all EntityManager instances
  • C A persistence unit defines a set of entity classes, persistence provider configuration, and database connection details in a named, reusable configuration unit ✓ Correct
  • D A persistence unit represents a transaction boundary that determines when changes are committed to the database and rolled back on errors
Explanation

A persistence unit is a logical grouping defined in persistence.xml that includes entity classes and provider configuration for a specific database connection.

Q14 Hard

In Jakarta Contexts and Dependency Injection, which mechanism allows you to inject different bean implementations based on runtime conditions?

  • A Qualifiers and producer methods ✓ Correct
  • B Bean aliases and inheritance hierarchies
  • C Interceptors and decorators
  • D Stereotypes and scope annotations
Explanation

Qualifiers are custom annotations that disambiguate between multiple implementations, and producer methods allow creating bean instances programmatically based on conditions.

Q15 Medium

Which Jakarta Enterprise Beans transaction attribute ensures that if a transaction already exists, the method runs outside of it in a separate transaction?

  • A NOT_SUPPORTED
  • B NEVER
  • C REQUIRES_NEW ✓ Correct
  • D MANDATORY
Explanation

REQUIRES_NEW always creates a new transaction for the method invocation, suspending any existing transaction if one is active.

Q16 Medium

In Jakarta RESTful Web Services, what is the purpose of the @Produces annotation on a resource method?

  • A To specify the media types that the method is able to generate and return in the response ✓ Correct
  • B To declare that the method produces side effects and should not be cached by clients or proxies
  • C To indicate that the method produces database records or persisted entity instances
  • D To mark the method as producing output that should be serialized in a specific format for logging purposes
Explanation

@Produces specifies the media type(s) (e.g., application/json) that a resource method can return, enabling content negotiation based on client Accept headers.

Q17 Medium

Which of the following best describes the purpose of named queries in Jakarta Persistence?

  • A To establish database views that improve query performance by pre-aggregating data from multiple tables
  • B To define reusable query definitions that are compiled and validated at application startup, improving performance and maintainability ✓ Correct
  • C To group queries by name for organizational purposes without affecting their execution strategy
  • D To create temporary queries that are executed immediately when the entity class is loaded into memory
Explanation

Named queries are defined using @NamedQuery annotations and are parsed at startup, allowing for validation and optimization before runtime execution.

Q18 Easy

In Jakarta Servlet technology, which interface must be implemented to create a filter that can intercept and modify requests and responses?

  • A HttpSession
  • B HttpServlet
  • C Filter ✓ Correct
  • D ServletContext
Explanation

The Filter interface defines the contract for request/response filters with doFilter(), init(), and destroy() methods for intercepting servlet processing.

Q19 Medium

Which Jakarta Contexts and Dependency Injection feature allows you to intercept method calls on managed beans to apply cross-cutting concerns?

  • A Qualifiers
  • B Decorators
  • C Observers
  • D Interceptors ✓ Correct
Explanation

Interceptors are used to intercept method invocations on managed beans to implement cross-cutting concerns like logging, security, or transaction handling.

Q20 Hard

In Jakarta Persistence, which mapping annotation establishes a bidirectional one-to-one relationship and indicates which side owns the relationship?

  • A @OneToOne with @PrimaryKeyJoinColumn for using primary key as foreign key
  • B @OneToOne with mappedBy attribute on the non-owning side ✓ Correct
  • C @JoinColumn on both sides to explicitly define the foreign key
  • D @OneToOne with @JoinTable to create an association table
Explanation

The owning side of a one-to-one relationship uses @JoinColumn, while the non-owning side uses mappedBy to reference the owning side's attribute name.

Q21 Medium

Which Jakarta Enterprise Beans interceptor annotation is used to invoke a method after the bean method completes but before control returns to the client?

  • A @PrePassivate
  • B @AroundInvoke ✓ Correct
  • C @PostInvoke
  • D @AfterInvoke
Explanation

@AroundInvoke defines an interceptor method that wraps the entire bean method execution, allowing control before and after the invocation.

Q22 Hard

In Jakarta RESTful Web Services, which annotation is used to indicate that a path parameter value should be converted to a specific type like UUID or LocalDate?

  • A @Convert
  • B @ParamConverter ✓ Correct
  • C @TypeMap
  • D @PathParam with a type conversion class
Explanation

@ParamConverter allows you to register custom converters for converting path, query, and header parameter values to application-specific types.

Q23 Hard

Which of the following statements accurately describes the difference between optimistic and pessimistic locking in Jakarta Persistence?

  • A Both approaches use the same mechanism but pessimistic locking is preferred for read-heavy workloads
  • B Pessimistic locking is faster because it prevents lock conflicts while optimistic locking retries failed transactions automatically
  • C Optimistic locking requires manual intervention while pessimistic locking is completely transparent to the application
  • D Optimistic locking uses version columns to detect concurrent modifications while pessimistic locking acquires database locks to prevent modification ✓ Correct
Explanation

Optimistic locking detects conflicts after they occur using version fields, while pessimistic locking prevents conflicts by acquiring exclusive locks before modification.

Q24 Medium

In Jakarta Batch, which artifact is responsible for orchestrating the overall execution flow of a batch job including steps and their sequence?

  • A Job ✓ Correct
  • B JobInstance
  • C BatchContext
  • D Step
Explanation

A Job defines the overall batch processing configuration including the steps to be executed and their orchestration within the batch framework.

Q25 Easy

Which Jakarta EE specification defines the standard for building RESTful web services?

  • A Jakarta Bean Validation
  • B Jakarta WebSocket
  • C Jakarta RESTful Web Services (REST) ✓ Correct
  • D Jakarta Servlet
Explanation

Jakarta RESTful Web Services (formerly JAX-RS) provides annotations and APIs for building REST endpoints. It is the standard specification for RESTful services in Jakarta EE.

Q26 Medium

In a Jakarta EE application, what is the primary purpose of the @Transactional annotation?

  • A To enable caching of method results across requests
  • B To define transaction boundaries and manage commit/rollback behavior ✓ Correct
  • C To mark a method as requiring database access only
  • D To specify which database connection pool to use
Explanation

@Transactional controls whether a method executes within a transaction context and defines rollback behavior. It is essential for ACID compliance in enterprise applications.

Q27 Medium

Which of the following best describes the role of Jakarta Dependency Injection (CDI)?

  • A It provides a standard mechanism for loose coupling through constructor and field injection of managed beans ✓ Correct
  • B It manages the lifecycle of database connection pools
  • C It specifies the format for storing application configuration in XML files
  • D It defines how to serialize objects for network transmission
Explanation

CDI provides a standardized dependency injection framework allowing loose coupling between components through annotations like @Inject. It manages bean discovery, scoping, and lifecycle.

Q28 Medium

What is the default scope for a CDI bean if no scope annotation is specified?

  • A Session scope
  • B Request scope
  • C Application scope
  • D Dependent scope ✓ Correct
Explanation

When no explicit scope is declared, a CDI bean defaults to @Dependent scope, meaning it exists only for its injection point and has no shared lifecycle.

Q29 Easy

In Jakarta Persistence (JPA), which annotation is used to define a one-to-many relationship from the 'one' side?

  • A @ManyToOne
  • B @OneToMany ✓ Correct
  • C @ManyToMany
  • D @JoinColumn
Explanation

@OneToMany defines a relationship where one entity can be associated with multiple instances of another entity. It is placed on the collection property on the owning side.

Q30 Medium

When using Jakarta Persistence, what is the purpose of the @Version annotation?

  • A To define the entity class version for backward compatibility
  • B To indicate which database version is required for compatibility
  • C To enable optimistic locking and detect concurrent modifications to an entity ✓ Correct
  • D To specify the version of the JPA specification being used
Explanation

@Version implements optimistic locking by maintaining a version field that increments on each update, allowing detection of concurrent modifications and preventing lost updates.

Q31 Medium

Which Jakarta EE API is specifically designed for declarative security in web applications?

  • A Jakarta Security ✓ Correct
  • B Jakarta Authentication
  • C Jakarta Cryptography
  • D Jakarta Authorization
Explanation

Jakarta Security provides simplified APIs for authentication and authorization using standard mechanisms like OpenID Connect and OAuth 2.0, along with declarative security annotations.

Q32 Easy

In Jakarta Servlet, what does the @WebServlet annotation allow you to do?

  • A Declare and configure a servlet without requiring a deployment descriptor ✓ Correct
  • B Specify which port the application should listen on
  • C Automatically generate servlet class files from annotations
  • D Enable compression of HTTP responses
Explanation

@WebServlet is a metadata annotation that allows servlet declaration directly in code, eliminating the need for web.xml configuration entries.

Q33 Medium

What is the primary difference between @PrePersist and @PostPersist lifecycle callbacks in JPA?

  • A @PrePersist requires a database transaction, @PostPersist does not
  • B @PrePersist works on new entities, @PostPersist works on existing entities
  • C @PrePersist is for validation, @PostPersist is for logging only
  • D @PrePersist executes before INSERT, @PostPersist executes after INSERT completes ✓ Correct
Explanation

@PrePersist fires before the database INSERT executes, allowing pre-insert logic like timestamp setting. @PostPersist fires after the INSERT succeeds, useful for post-insert operations.

Q34 Easy

In a REST API using Jakarta REST, how would you specify that a method parameter comes from the request path?

  • A Using the @FormParam annotation
  • B Using the @PathParam annotation ✓ Correct
  • C Using the @QueryParam annotation
  • D Using the @HeaderParam annotation
Explanation

@PathParam binds method parameters to URI template variables defined in the @Path annotation, extracting path segments from the request URL.

Q35 Medium

Which of the following scenarios would benefit most from using Jakarta Batch?

  • A Managing WebSocket connections for live chat applications
  • B Validating user input in form submissions
  • C Processing millions of records in scheduled jobs with checkpointing and retry capabilities ✓ Correct
  • D Handling individual HTTP requests from users in real-time
Explanation

Jakarta Batch is designed for large-scale batch processing with features like item-oriented processing, chunking, checkpointing, and restart capabilities for fault-tolerant job execution.

Q36 Hard

In Jakarta EE, what is the purpose of a qualifier annotation in CDI?

  • A To define performance optimization hints for the container
  • B To indicate which classloader should load a bean
  • C To distinguish between multiple implementations of the same interface at injection points ✓ Correct
  • D To specify the quality of service level for a service
Explanation

Qualifiers allow you to create custom annotations that distinguish between multiple beans of the same type, enabling precise bean selection during injection.

Q37 Medium

What does the @Stateless annotation indicate in Jakarta Enterprise Beans (EJB)?

  • A The bean is only accessible to stateless protocols like REST
  • B The bean maintains no conversational state between method invocations and can be pooled ✓ Correct
  • C The bean cannot access any session information from HTTP requests
  • D The bean is immutable and cannot be modified after creation
Explanation

@Stateless declares a session bean that doesn't maintain client-specific state, allowing the container to pool and reuse instances across multiple clients for better performance.

Q38 Easy

In Jakarta Persistence, which query language is used to write database-agnostic queries?

  • A Jakarta Persistence Query Language (JPQL) ✓ Correct
  • B XPath
  • C SQL
  • D HQL (Hibernate Query Language)
Explanation

JPQL is an object-oriented query language independent of the underlying database, allowing queries to be written against entity classes rather than raw database tables.

Q39 Hard

What is the correct sequence of container-managed transaction boundaries for a method marked @Transactional(TxType.REQUIRED)?

  • A Transaction is started by the method itself; container cannot control it
  • B Transaction starts before method execution; commits or rolls back after method completes ✓ Correct
  • C Transaction is suspended before method execution and resumed after
  • D Transaction commits immediately after method parameters are validated
Explanation

REQUIRED ensures a transaction exists before method execution—either using an existing one or creating a new one—and the container manages commit/rollback based on method completion.

Q40 Medium

Which Jakarta EE specification provides support for asynchronous message-driven processing?

  • A Jakarta Mail
  • B Jakarta Concurrency
  • C Jakarta Messaging (JMS) ✓ Correct
  • D Jakarta WebSocket
Explanation

Jakarta Messaging provides asynchronous, loosely-coupled communication between applications through message brokers, supporting both point-to-point and publish-subscribe models.

Q41 Easy

In a REST service, what HTTP status code should be returned when a POST request successfully creates a new resource?

  • A 201 Created ✓ Correct
  • B 204 No Content
  • C 202 Accepted
  • D 200 OK
Explanation

HTTP 201 Created is the correct response for successful resource creation, typically including a Location header with the URI of the newly created resource.

Q42 Hard

What is the primary advantage of using CDI events with @Observes over direct method calls in an enterprise application?

  • A Events enable loose coupling between components by decoupling publisher from observer implementations ✓ Correct
  • B Events automatically persist data to the database
  • C Events guarantee execution order across all observers
  • D Events execute faster than direct method calls
Explanation

Events decouple event producers from observers, allowing dynamic addition of new observers without modifying publisher code, improving maintainability and testability.

Q43 Medium

In Jakarta Bean Validation, which annotation validates that a string matches a regular expression?

  • A @Expression
  • B @Regex
  • C @Pattern ✓ Correct
  • D @Match
Explanation

@Pattern constraint validates that a string field matches the provided regular expression pattern, useful for enforcing format requirements like email or phone numbers.

Q44 Medium

What is the primary purpose of the persistence.xml file in Jakarta Persistence?

  • A To define user roles and security permissions
  • B To store SQL queries used by the application
  • C To define persistence units and their configuration, including data source and ORM settings ✓ Correct
  • D To specify which Java classes are entity classes
Explanation

persistence.xml is the configuration file for JPA persistence units, specifying the datasource, ORM provider, entity classes, and various provider-specific properties.

Q45 Hard

When using @Produces in CDI, what does it allow you to do?

  • A Produce database connections directly without a connection pool
  • B Produce compiled bytecode from source annotations
  • C Generate injectable beans from methods or fields without direct instantiation ✓ Correct
  • D Generate HTML content automatically from Java objects
Explanation

@Produces marks a method or field as a producer, allowing the container to inject complex objects—like configurations or API clients—as if they were regular beans.

Q46 Easy

In Jakarta REST, which annotation is used to specify the media type(s) that a resource produces?

  • A @Produces ✓ Correct
  • B @MediaType
  • C @Consumes
  • D @ContentType
Explanation

@Produces declares the media types a method can return (e.g., application/json), allowing content negotiation and proper response serialization based on client preferences.

Q47 Medium

What is the key difference between @Stateful and @Stateless session beans in EJB?

  • A @Stateful is faster than @Stateless because it doesn't use pooling
  • B @Stateful can only be accessed through remote interfaces
  • C @Stateful maintains conversational state across method invocations; @Stateless does not and is pooled ✓ Correct
  • D @Stateless supports persistence while @Stateful does not
Explanation

@Stateful beans maintain client-specific state across multiple invocations, while @Stateless beans are stateless and pooled, making them more scalable for high-throughput scenarios.

Q48 Hard

In a Jakarta Persistence query using JPQL, what is the purpose of the FETCH JOIN clause?

  • A To eagerly load related entities in a single query to prevent N+1 problems ✓ Correct
  • B To specify the order in which entities are retrieved from the database
  • C To limit the number of related entities loaded per parent entity
  • D To download files from remote servers during entity loading
Explanation

FETCH JOIN eagerly loads related entities in one query round-trip, preventing the N+1 query problem that occurs when lazy-loading relationships in loops.

Q49 Medium

You are designing a Java EE application that requires transaction management across multiple databases. Which annotation should you use to declaratively manage transaction boundaries in an EJB session bean?

  • A @ManagedTransaction(scope=APPLICATION)
  • B @Transactional(propagation=REQUIRED)
  • C @TransactionAttribute(TransactionAttributeType.REQUIRED) ✓ Correct
  • D @JoinTransaction
Explanation

The @TransactionAttribute annotation is the standard EJB declarative transaction management mechanism that controls transaction propagation behavior. While @Transactional exists in Spring, the exam focuses on Java EE standards.

Q50 Medium

When using JPA in a container-managed environment, what is the scope of a transaction-scoped persistence context?

  • A The persistence context persists for the lifetime of the EntityManagerFactory
  • B The persistence context is thread-local and shared across multiple transactions in the same thread
  • C The persistence context is created at the beginning of a transaction and closed when the transaction commits or rolls back ✓ Correct
  • D The persistence context is shared across all requests within a single HTTP session
Explanation

A transaction-scoped persistence context is automatically created when a transaction begins and is closed when it ends, ensuring entities are managed only during the active transaction. This is the default and most common persistence context scope in Java EE.

Q51 Easy

You need to implement security in a Java EE application where certain business methods should only be accessible to users with the 'ADMIN' role. Which approach is BEST for declarative method-level security?

  • A Wrapping method calls with explicit Principal verification code
  • B Implementing the SecurityManager interface in the bean class
  • C @RolesAllowed("ADMIN") annotation on the business method ✓ Correct
  • D Configuring role-based access in the web.xml deployment descriptor only
Explanation

@RolesAllowed is the standard Java EE annotation for declarative method-level authorization that allows you to specify which roles can invoke a protected method. This provides clean, maintainable security without hardcoding authorization logic.

Q52 Medium

In a JPA entity relationship, you have defined a OneToMany association with cascade=CascadeType.ALL. What happens when you delete a parent entity that has active child entities?

  • A The child entities are automatically deleted from the database due to the cascade delete operation ✓ Correct
  • B Only the parent entity is deleted; child entities remain in the database orphaned
  • C A constraint violation exception is raised to prevent accidental data loss
  • D The child entities are detached from persistence context but not deleted from the database
Explanation

CascadeType.ALL includes CascadeType.REMOVE, which means delete operations on the parent are cascaded to all associated child entities. This automatically removes child records when the parent is deleted.

Q53 Hard

You are implementing message-driven bean (MDB) processing for an application. The onMessage() method throws an unchecked exception. What is the default behavior?

  • A The application server shuts down the MDB container to prevent further message processing
  • B The container rolls back the transaction (if container-managed), and the message is redelivered according to the configured redelivery policy ✓ Correct
  • C The message is immediately redelivered to the queue; the container retries processing indefinitely
  • D The message is removed from the queue and logged; processing continues with the next message
Explanation

When an exception is thrown in an MDB's onMessage() method, the container-managed transaction is rolled back and the message is typically returned to the queue for redelivery based on the messaging provider's retry configuration.

Q54 Medium

Which of the following statements about servlet filters is correct?

  • A A filter can terminate request processing by not calling chain.doFilter() and sending a response directly to the client ✓ Correct
  • B Filters can only be applied to servlet requests, not to include or forward operations
  • C Multiple filters are executed in the reverse order they are declared in web.xml when the response returns through the filter chain
  • D Filters have access to the servlet container's JNDI naming context but cannot access HttpSession objects
Explanation

Filters can prevent propagation through the chain by not invoking chain.doFilter(), allowing them to send a response or redirect directly. This is commonly used for authentication, logging, and request validation before reaching the servlet.

Q55 Hard

In a clustered Java EE environment, you need to ensure session replication across cluster nodes. Which session persistence mechanism is MOST appropriate for high-availability requirements?

  • A Serializing sessions to a shared database or persistent store that all cluster nodes can access ✓ Correct
  • B Using local file system storage with manual synchronization between cluster nodes
  • C Storing sessions exclusively in client-side cookies with HTTPS encryption
  • D In-memory session storage without replication for maximum performance
Explanation

Database-backed or shared persistent storage enables session replication across cluster nodes, ensuring sessions survive node failures. This is the standard approach for high-availability clustering in Java EE environments.

Q56 Hard

When using JPQL, what is the primary difference between the JOIN and JOIN FETCH keywords in a query?

  • A JOIN FETCH always returns more rows than JOIN because it includes duplicate entities
  • B JOIN can only be used with bidirectional relationships, while JOIN FETCH works with unidirectional relationships
  • C There is no functional difference; they are aliases for the same operation
  • D JOIN FETCH eagerly loads the related entities into the persistence context to avoid lazy loading exceptions, while JOIN does not guarantee eager loading ✓ Correct
Explanation

JOIN FETCH explicitly loads associated entities in the same query to populate the object graph, preventing lazy loading exceptions later. Regular JOIN only filters results but doesn't guarantee the related entities are loaded into the persistence context.

Q57 Easy

You are configuring a WebSocket endpoint in a Java EE application. Which annotation indicates that a class should be treated as a WebSocket server endpoint?

  • A @ServerEndpoint("/path/to/endpoint") ✓ Correct
  • B @WebSocketServer
  • C @EnableWebSocket
  • D @WebSocket(type=SERVER)
Explanation

@ServerEndpoint is the standard Java EE (JSR 356) annotation that marks a class as a WebSocket server endpoint and requires specifying the URI path where clients can connect.

Q58 Medium

In a Java EE application using bean validation (JSR 380), you have applied multiple custom validators to a single field. How are multiple validation constraint violations handled?

  • A Only the first validation constraint is checked; subsequent constraints are ignored
  • B The validator immediately throws an exception after the first constraint violation
  • C All applicable constraints are validated, and all violations are accumulated and returned in the ConstraintViolation set ✓ Correct
  • D The application must explicitly configure which constraint takes precedence over others
Explanation

Bean Validation collects ALL constraint violations across all validators applied to a field and returns them in a Set<ConstraintViolation<T>>, allowing comprehensive validation error reporting rather than fail-fast behavior.

Ready to test your knowledge?

You've reviewed all 58 questions. Take the interactive practice exam to simulate the real test environment.

▶ Start Practice Exam — Free