Docsity

WGU D387 ADVANCED JAVA PA COMPLETE TASK 1 GUIDE | SPRING BOOT, ANGULAR, MULTITHREADING & D, Exams of Nursing

Toggle sidebar
bg1
WGU D387 ADVANCED JAVA PA COMPLETE
TASK 1 GUIDE | SPRING BOOT, ANGULAR,
MULTITHREADING & DOCKER | 2026 UPDATE.
149 Questions with Answers and Detailed Rationales
100 PERCENT GUARANTEED PASS
INSTANT DOWNLOAD ANSWERS INCLUDED
IMPORTANCE OF THIS DOCUMENT
This comprehensive examination preparation guide has been meticulously developed to help you succeed in the
WGU D387 ADVANCED JAVA PA COMPLETE TASK 1 GUIDE | SPRING BOOT, ANGULAR,
MULTITHREADING & DOCKER | 2026 UPDATE.. It contains 149 carefully selected questions that reflect the
most current exam content and testing strategies. Each question is accompanied by a correct answer and a
detailed rationale that explains the underlying pathophysiology, pharmacology, or clinical reasoning.
Self-Assessment – Test your knowledge and
identify areas requiring further
study
Exam Preparation – Familiarize yourself with the
question format and content
areas
Concept Reinforcement – Deepen your
understanding through
evidence-based
rationales
Confidence Building – Develop test-taking
strategies and reduce
exam anxiety
Time Management – Practice answering
questions under simulated
exam conditions
Review Summary 149 Questions
Foundations - Application - WGU D387 Advanced JAVA PA Complete TASK 1 Guide Spring BOOT Angular
Multithreading & Docker 2026 Update Advanced JAVA Spring BOOT Angular Multithreading Docker Graduate
All answers with rationales
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46

Partial preview of the text

Download WGU D387 ADVANCED JAVA PA COMPLETE TASK 1 GUIDE | SPRING BOOT, ANGULAR, MULTITHREADING & D and more Exams Nursing in PDF only on Docsity!

WGU D387 ADVANCED JAVA PA COMPLETE

TASK 1 GUIDE | SPRING BOOT, ANGULAR,

MULTITHREADING & DOCKER | 2026 UPDATE.

149 Questions with Answers and Detailed Rationales

100 PERCENT GUARANTEED PASS

INSTANT DOWNLOAD ANSWERS INCLUDED

IMPORTANCE OF THIS DOCUMENT

This comprehensive examination preparation guide has been meticulously developed to help you succeed in the WGU D387 ADVANCED JAVA PA COMPLETE TASK 1 GUIDE | SPRING BOOT, ANGULAR, MULTITHREADING & DOCKER | 2026 UPDATE.. It contains 149 carefully selected questions that reflect the most current exam content and testing strategies. Each question is accompanied by a correct answer and a detailed rationale that explains the underlying pathophysiology, pharmacology, or clinical reasoning.

Self-Assessment – Test your knowledge and identify areas requiring further study

Exam Preparation – Familiarize yourself with the question format and content areas Concept Reinforcement – Deepen your understanding through evidence-based rationales

Confidence Building – Develop test-taking strategies and reduce exam anxiety Time Management – Practice answering questions under simulated exam conditions

Review Summary 149 Questions

Foundations - Application - WGU D387 Advanced JAVA PA Complete TASK 1 Guide Spring BOOT Angular Multithreading & Docker 2026 Update Advanced JAVA Spring BOOT Angular Multithreading Docker Graduate All answers with rationales

Table of Contents

Content Area Questions Key Topics

Spring BOOT Fundamentals 1-25 Application, Spring BOOT, Service, YOU NEED, Ensure

Restful WEB Services 26-50 Spring, Application, Method, Angular, Database

Angular Frontend Development

51-75 Application, Spring, YOU NEED, Approach, Ensure

DATA Persistence WITH Spring DATA

76-100 Spring, Application, Correctly, Tasks, Ensure

Multithreading AND Concurrency

101-125 Spring, Application, Angular, Image, YOU NEED

Docker Containerization 126-149 Spring, Application, Approach, Docker, YOU NEED

TOTAL 149 All questions include answers and detailed rationales

Section A - Spring BOOT Fundamentals

C. ExecutorService with Future.cancel(true) and interruptible tasks

D. CompletableFuture with exceptionally handling and no interruption Correct: C - ExecutorService with Future.cancel(true) and interruptible tasks

Rationale: Future.cancel(true) sends an interrupt to the worker thread, allowing tasks to respond to interruption and clean up. A volatile flag requires cooperative checking and may not interrupt blocking operations; ForkJoin cancellation is more complex; CompletableFuture without interruption cannot cancel running tasks.

Q4. When containerizing a Spring Boot application with Docker, you want to minimize the final image size and avoid including build tools. Which Dockerfile strategy achieves this most effectively?

A. Use a single base image with JDK and Maven, and run the app directly.

B. Use a multi-stage build: compile with Maven in a JDK image, then copy the JAR to a JRE image.

C. Use a base image with only the JRE and mount the source code as a volume.

D. Use a Dockerfile that runs Maven at container startup to compile the app. Correct: B - Use a multi-stage build: compile with Maven in a JDK image, then copy the JAR to a JRE image.

Rationale: Multi-stage builds separate build and runtime, copying only the compiled artifact to a slim JRE image. The other options either include build tools in the final image, require source code at runtime, or compile at startup, increasing size and complexity.

Q5. In a Spring Boot application, you need to enforce that certain fields are validated only when another field has a specific value. Which approach is most aligned with Bean Validation best practices?

A. Use @NotNull on all fields and handle conditional logic in the controller.

B. Use a custom class-level constraint that checks the condition.

C. Use @Valid on the object and @Pattern with regex on the conditional field.

D. Use @AssertTrue on a getter that checks the condition.

Correct: B - Use a custom class-level constraint that checks the condition.

Rationale: Custom class-level constraints allow cross-field validation, keeping validation logic in the model. Controller logic spreads validation concerns; @Pattern only validates format; @AssertTrue on getter is a workaround but less clean and doesn't support field-specific messages.

Section A - Spring BOOT Fundamentals

Q6. You are deploying a multi-container application with Docker Compose. You need to ensure that the database service starts before the backend service, and that the backend waits for the database to be ready. Which approach is most reliable?

A. Use depends_on with condition: service_healthy and a healthcheck in the database service.

B. Use depends_on without condition, assuming the container starts quickly.

C. Use a shell script in the backend that sleeps for a fixed time.

D. Use a custom entrypoint that retries database connection with a loop. Correct: A - Use depends_on with condition: service_healthy and a healthcheck in the database service.

Rationale: Healthchecks ensure the database is actually ready, not just started. depends_on with condition service_healthy is the proper Compose v2 feature. Fixed sleeps are unreliable; retry loops in entrypoints are manual and less declarative.

Q7. In an Angular application, you have a list of items and you want to update only the changed item in the DOM to improve performance. Which change detection strategy and trackBy function combination is correct?

A. Default change detection and trackBy: (index) => index

B. OnPush change detection and trackBy: (item) => item.id

C. Default change detection and no trackBy function

D. OnPush change detection and trackBy: (item) => item.name Correct: B - OnPush change detection and trackBy: (item) => item.id

Rationale: OnPush reduces change detection checks, and trackBy with a unique identifier allows Angular to reuse DOM elements and update only the changed items. Using index or name may cause unnecessary re-renders or miss updates.

Q8. You need to secure a Spring Boot REST API using OAuth2 with JWT tokens. You want to ensure that the JWT contains a custom claim for user roles and that the token is validated without contacting the authorization server on each request. Which configuration is necessary?

A. Use a JWT decoder with a public key and configure a custom claim set converter.

B. Use an opaque token with token introspection on every request.

C. Store roles in a database and look them up on each request.

D. Use JWT with a shared secret and no custom claims.

Section A - Spring BOOT Fundamentals

Q11. In a Spring Boot microservice using JPA, you must ensure that an entity's @Version field is incremented atomically during an optimistic lock update. Which strategy guarantees atomicity under high concurrency?

A. Use a long field annotated with @Version and rely on the persistence provider's automatic increment in the UPDATE statement.

B. Manually increment the version field in the service layer before calling save().

C. Use entityManager.lock(entity, LockMod eType.OPTIMISTIC_FORCE_INCREMENT) and then persist the entity.

D. Annotate the version field as @Version and use entityManager.merge() to force an increment. Correct: A - Use a long field annotated with @Version and rely on the persistence provider's automatic increment in the UPDATE statement.

Rationale: The JPA specification requires the persistence provider to include the version field in the UPDATE SET clause, incrementing it atomically. Manual increments (B) are unsafe because they are not part of the optimistic lock check. OPTIMISTIC_FORCE_INCREMENT (C) forces an increment even without changes but is not the default atomic mechanism. merge() (D) does not guarantee atomic increment if the version is not managed.

Q12. Given the following Angular code using the async pipe, what is the most likely outcome and why? items$ = this.service.getItems(); and template: {{item.name}}

A. The subscription is automatically managed; the async pipe unsubscribes on component destroy.

B. The async pipe creates a new subscription every change detection cycle, causing memory leaks.

C. The async pipe requires an initial value; otherwise it throws an error.

D. The async pipe will not update the view when the observable emits because it lacks a trackBy function. Correct: A - The subscription is automatically managed; the async pipe unsubscribes on component destroy.

Rationale: The async pipe subscribes to the observable and automatically unsubscribes when the component is destroyed, preventing memory leaks. It does not create new subscriptions per cycle (B) because it reuses the same subscription. It does not require an initial value (C); it simply renders nothing until the first emission. trackBy (D) is an optimization for *ngFor, not required for the async pipe to update.

Section A - Spring BOOT Fundamentals

Q13. In a Java application, you need to execute a long-running computation in parallel while limiting the number of concurrent threads to 4. Which construct is most appropriate, and why?

A. Use Executors.newFixedThreadPool(4) and submit tasks via invokeAll().

B. Use CompletableFuture.supplyAsync() without an executor; it defaults to a common pool sized to CPU cores.

C. Use ForkJoinPool.commonPool() and rely on work stealing to limit concurrency.

D. Use Executors.newCachedThreadPool() because it automatically limits to 4 threads under load. Correct: A - Use Executors.newFixedThreadPool(4) and submit tasks via invokeAll().

Rationale: A fixed thread pool with 4 threads ensures at most 4 concurrent tasks. invokeAll() blocks until all tasks complete, which is appropriate for parallel computation. supplyAsync() without an executor uses the common pool, which may have more threads. ForkJoinPool.commonPool() also uses a default parallelism. A cached thread pool creates unlimited threads.

Q14. You are containerizing a Spring Boot application. Which Dockerfile instruction is most critical to ensure the application runs as a non-root user and follows security best practices?

A. RUN addgroup -S app && adduser -S app -G app followed by USER app

B. `ENV

SPRING_PROFILES_ACTIVE=prod`

C. EXPOSE 8080 D. COPY --chown=app:app target/app.jar app.jar Correct: A - RUN addgroup -S app && adduser -S app -G app followed by USER app

Rationale: Creating a dedicated user and switching to it with USER prevents the container from running as root, a critical security best practice. The other options are useful but not as critical for security: ENV sets environment, EXPOSE documents ports (does not actually open them), and COPY --chown sets file ownership but does not switch the runtime user.

Q15. In a Spring Boot application, you have a @RestController that throws a custom BusinessException. You want to return a structured error response with a timestamp and a correlation ID. What is the best approach?

Section A - Spring BOOT Fundamentals

C. Use docker commit to create an image from a running container after manual configuration.

D. Use a base image that includes both the JDK and Maven, and copy the entire project directory. Correct: A - Use a multi-stage build: first stage compiles the app with Maven, second stage copies the JAR into a JRE base image.

Rationale: Multi-stage builds allow you to compile in a builder stage with Maven and then copy only the resulting JAR into a slim JRE image, drastically reducing size. Single-stage with the full JDK (B) is larger. docker commit (C) is not reproducible and inefficient. Copying the entire project (D) includes unnecessary files and uses a heavier image.

Q18. In a Java 17 application, you have a CompletableFuture chain: CompletableFuture.supplyAsync(() -> task1()).thenApplyAsync(r -> task2(r)).thenAcceptAsync(r -> task3(r)). If task1() throws an unchecked exception, what happens?

A. The exception is propagated to the thread that called join() or get(), and the subsequent stages are skipped.

B. The exception is swallowed, and task2 and task3 are executed with a null value.

C. The exception is caught by the thenApplyAsync stage, and task3 is executed with the exception as input.

D. The entire chain completes exceptionally, but task3 still runs because it is an accept stage. Correct: A - The exception is propagated to the thread that called join() or get(), and the subsequent stages are skipped.

Rationale: In CompletableFuture, if a stage completes exceptionally, dependent stages are not executed. The exception is stored and rethrown when join() or get() is called. thenApplyAsync and thenAcceptAsync do not handle exceptions; they are skipped. The exception is not swallowed (B) or passed as input (C). task3 does not run (D).

Q19. You are deploying a Spring Boot application to a Docker container on a host that already runs another service on port 8080. Which Docker run command correctly maps the container's port 8080 to an available host port?

A. docker run -p 8080:8080 myapp B. docker run -p 8081:8080 myapp

C. docker run --expose 8080 myapp D. docker run -P myapp Correct: B - docker run -p 8081:8080 myapp

Section A - Spring BOOT Fundamentals

Rationale: The -p flag maps host port to container port. To avoid conflict, map to a different host port (8081) while keeping container port 8080. Option A would conflict. --expose (C) only documents the port, does not publish. -P (D) publishes all exposed ports to random host ports, not a specific port.

Q20. In a Spring Boot application, you need to ensure that a service method is transactional and rolls back on any RuntimeException, but not on checked exceptions. Which annotation configuration is correct?

A. @Transactional(rollbackFor = Exception.class)

B. @Transactional(noRollbackFor = RuntimeException.class)

C. @Transactional (default behavior) D. @Transactional(rollbackFor = RuntimeException.class, noRollbackFor = CheckedException.class) Correct: C - @Transactional (default behavior)

Rationale: Spring's @Transactional by default rolls back on unchecked exceptions (RuntimeException and Error) but not on checked exceptions. This matches the requirement. Option A rolls back on all exceptions, which is broader. Option B would prevent rollback on runtime exceptions, the opposite. Option D is redundant and does not change the default for checked exceptions.

Q21. In a Spring Boot microservice, a @RestController method returns a ResponseEntity with a custom Cache-Control header. The service is deployed behind a reverse proxy that also sets Cache-Control. Which annotation or configuration ensures the proxy does not override the application's header?

A. Add @CrossOrigin with allowCredentials = true

B. Configure server.forward-headers-strate gy=framework

C. Use @ResponseBody with produces = "application/json"

D. Implement a WebMvcConfigurer to add an interceptor that sets the header on every response Correct: B - Configure server.forward-headers-strategy=framework

Rationale: Setting server.forward-headers-strategy=framework makes Spring Boot respect forwarded headers from the proxy, allowing the application's Cache-Control to be honored. @CrossOrigin handles CORS, not header overriding. @ResponseBody just binds the return value. An interceptor would not prevent the proxy from overwriting unless configured to use forwarded headers.

Section A - Spring BOOT Fundamentals and the JAR is executable?

A. RUN adduser -D appuser && USER appuser before copying the JAR

B. RUN chmod 777 /app.jar && USER appuser

C. COPY --from=build /app/target/app.jar /app.jar and then RUN chown appuser:appuser /app.jar

D. USER 1000:1000 and ENTRYPOINT ["java", "-jar", "/app.jar"] without changing permissions Correct: C - COPY --from=build /app/target/app.jar /app.jar and then RUN chown appuser:appuser /app.jar

Rationale: After copying the JAR, you need to change ownership to the non-root user to avoid permission issues. RUN adduser before copying would leave the file owned by root. chmod 777 is insecure. Simply using USER 1000:1000 may fail if the JAR is not readable or executable by that user.

Q25. In a Spring Boot application, you have a @ConfigurationProperties class for external service credentials. You want to ensure that a specific property is required and the application fails fast if missing. Which approach is correct?

A. Add @Validated and use @NotNull on the field, and set spring.config.import=optional:configserver:

B. Use @Value("${service.api-key}") on the field and let Spring throw IllegalArgumentException

C. Implement ApplicationRunner to check the property and throw an exception

D. Add a @PostConstruct method that throws BeanCreationException if the property is null Correct: A - Add @Validated and use @NotNull on the field, and set spring.config.import=optional:configserver:

Rationale: Using @Validated with @NotNull on a @ConfigurationProperties field triggers validation during binding, causing startup failure if missing. @Value would throw a placeholder resolution exception, but that's not the recommended way for configuration properties. ApplicationRunner runs after startup, not fail-fast. @PostConstruct is not the standard validation mechanism.

Section B - Restful WEB Services

Q26.

You are designing an Angular service that makes HTTP requests. To handle race conditions where a user quickly changes filters, you need to cancel the previous HTTP request when a new one is made. Which RxJS approach should you use?

A. Use switchMap on a Subject that emits filter changes

B. Use mergeMap with a takeUntil on a component destroy subject

C. Use exhaustMap to ignore new requests while one is in flight

D. Use concatMap to queue requests in order Correct: A - Use switchMap on a Subject that emits filter changes

Rationale: switchMap cancels the previous inner observable when a new value arrives, ideal for search-as-you-type scenarios. mergeMap would run all requests concurrently. exhaustMap ignores new emissions while the current request is active, which is not what you want. concatMap queues them, not cancels.

Q27. In a Java application, you have a CompletableFuture that performs a long-running computation. You want to handle exceptions and provide a fallback value. Which chain is correct for fallback and also ensures the original exception is not lost?

A. future.exceptionally(ex -> fallback).whenComplete((res, ex) -> log(ex))

B. future.handle((res, ex) -> ex != null? fallback : res)

C. future.thenApply(res -> res).exceptionally(ex -> fallback)

D. future.thenCompose(res -> Completable Future.completedFuture(fallback)).exception ally(ex -> fallback) Correct: B - future.handle((res, ex) -> ex != null? fallback : res)

Rationale: handle receives both result and exception, allowing you to return a fallback while still having access to the exception for logging or rethrowing. exceptionally only provides the exception, and if used with whenComplete, the original exception is still accessible but the fallback result is the final result. Option C works but is less direct. Option D incorrectly composes a fallback without checking the exception.

Q28. In a Docker Compose setup for a Spring Boot app and a PostgreSQL database, you need to ensure the app starts only after the database is healthy. Which configuration achieves this?

Section B - Restful WEB Services

Rationale: In the interceptor, you need to catch the 401 error, refresh the token, and then re-issue the original request. catchError with switchMap to next.handle(request) is the correct pattern. retryWhen would retry without refreshing the token. Returning EMPTY swallows the request. tap doesn't allow you to retry.

Q31. In a Spring Boot microservice, you must ensure that a complex domain event published during a transactional operation is dispatched only after the database transaction commits. Which combination of Spring constructs best guarantees this without risking duplicate or lost events?

A. Use @TransactionalEventListener with phase = TransactionPhase.AFTER_COMMIT and make the event listener idempotent.

B. Use @EventListener with @Async to dispatch the event asynchronously.

C. Use @Transactional(propagation = Propagation.REQUIRES_NEW) on the event publishing method.

D. Use ApplicationEventPublisher.publishEvent inside a @PostConstruct method. Correct: A - Use @TransactionalEventListener with phase = TransactionPhase.AFTER_COMMIT and make the event listener idempotent.

Rationale: Transaction synchronization ensures the event is only handled after commit, avoiding side effects on rollback. Idempotency guards against duplicate delivery. @Async alone risks race conditions, REQUIRES_NEW may commit prematurely, and @PostConstruct is not tied to a transaction.

Q32. An Angular 17 standalone component uses the new control flow syntax. Which template snippet correctly renders a list of items with an index and a fallback when the list is empty?

A. {{ i }}: {{ item }}No items

B. @for (item of items; track item; let i = $index) { {{ i }}: {{ item }} } @empty {

No items

}

C. {{ i }}: {{ item }}

D. @for (item of items; track item) { {{ item }} } @else {

No items

}

**Correct: B - @for (item of items; track item; let i = $index) { {{ i }}: {{ item }} } @empty {

No items

}**

Rationale: Angular 17's @for block uses track and $index, with @empty for the empty case. Option A uses the deprecated NgForOf syntax, C lacks an empty state, and D uses a non-existent @else.

Section B - Restful WEB Services

Q33. In a Java 21 virtual-thread-based system, you have a method that performs a blocking I/O call using synchronized. Which statement about scalability is true?

A. Virtual threads are pinned during synchronized blocks, limiting scalability if the blocking call is inside the block.

B. Synchronized blocks always release the underlying carrier thread, so virtual threads remain scalable.

C. The synchronized keyword is deprecated for virtual threads; use ReentrantLock instead.

D. Virtual threads cannot use synchronized; they must use LockSupport.park.

Correct: A - Virtual threads are pinned during synchronized blocks, limiting scalability if the blocking call is inside the block.

Rationale: Virtual threads are pinned to the carrier thread when inside a synchronized block, preventing unmounting and defeating scalability. ReentrantLock does not pin. Synchronized is not deprecated, and virtual threads can use it.

Q34. You are containerizing a Spring Boot application that reads database credentials from environment variables. Which Dockerfile approach best adheres to security best practices while keeping the image small?

A. Use a multi-stage build: Maven for compilation, then copy the JAR into a JRE runtime image; pass credentials at runtime via --env-file.

B. Use a single FROM maven:3.9-eclipse-temurin-21 image and set ENV for credentials in the Dockerfile.

C. Use FROM openjdk:11-jre and embed the credentials in the application.properties file inside the image.

D. Use a multi-stage build, but bake the credentials into the image using ARG during build. Correct: A - Use a multi-stage build: Maven for compilation, then copy the JAR into a JRE runtime image; pass credentials at runtime via --env-file.

Rationale: Multi-stage builds reduce size. Passing credentials at runtime via --env-file avoids baking secrets into the image. Single-stage images are larger, and embedding secrets in the image is insecure.

Q35. In a Spring Boot application, you have a service method annotated with @Transactional. The method calls another method within the same class that is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW). What actually happens when the inner method is invoked?

Section B - Restful WEB Services

Q38. Which Java concurrent construct is most appropriate for a bounded buffer shared by multiple producers and consumers, where producers must block when the buffer is full and consumers when empty?

A. ArrayBlockingQueue with put() and take() B. ConcurrentLinkedQueue with offer() and poll()

C. CopyOnWriteArrayList with add() and remove()

D. SynchronousQueue with offer() and poll()

Correct: A - ArrayBlockingQueue with put() and take()

Rationale: ArrayBlockingQueue is a bounded blocking queue that blocks on put() and take(). ConcurrentLinkedQueue is unbounded and non-blocking, CopyOnWriteArrayList is for read-heavy scenarios, and SynchronousQueue has no capacity.

Q39. You are using Spring Data JPA with Hibernate. Which fetch strategy is most likely to cause the N+1 query problem?

A. FetchType.LAZY on a @OneToMany association when iterating over the collection without a join fetch.

B. FetchType.EAGER on a @ManyToOne association.

C. Using @EntityGraph with attributeNodes for the association.

D. Using a JPQL query with JOIN FETCH.

Correct: A - FetchType.LAZY on a @OneToMany association when iterating over the collection without a join fetch.

Rationale: LAZY collections cause a separate query for each parent if accessed individually, leading to N+1. EAGER on ManyToOne is typically a single join, and @EntityGraph or JOIN FETCH explicitly avoid N+1.

Q40. In an Angular application, you need to display a list of 10,000 items with a custom tooltip on each item. Which approach best maintains performance?

A. Use virtual scrolling with Angular CDK and render the tooltip only when the item is hovered.

B. Use *ngFor to render all items and attach a (mouseenter) listener to each.

C. Use a single tooltip component that is positioned based on the hovered item's coordinates.

D. Use ChangeDetectionStrategy.Default and rely on Angular's built-in optimizations.

Correct: A - Use virtual scrolling with Angular CDK and render the tooltip only when the

Section B - Restful WEB Services item is hovered.

Rationale: Virtual scrolling renders only visible items, drastically reducing DOM nodes. Lazy tooltips avoid creating tooltip elements for off-screen items. Option C is a common technique but without virtual scrolling, 10,000 DOM nodes still hurt performance.

Q41. When configuring a Spring Boot application for deployment with Docker, which combination of practices ensures that the container image is both minimal and secure?

A. Use a multi-stage build with a JRE base image, run as a non-root user, and use a read-only root filesystem.

B. Use a single-stage build with a JDK base image, run as root, and mount the application jar as a volume.

C. Use a multi-stage build with a JDK base image, run as root, and set the entrypoint to a shell script.

D. Use a single-stage build with a JRE base image, run as a non-root user, and rely on the default overlay filesystem. Correct: A - Use a multi-stage build with a JRE base image, run as a non-root user, and use a read-only root filesystem.

Rationale: A multi-stage build separates build-time dependencies from runtime, allowing a minimal JRE base image. Running as a non-root user and using a read-only root filesystem are security best practices that reduce attack surface. The other options either include unnecessary build tools, run as root, or compromise security.

Q42. Given the following Angular service method, what is the most appropriate way to handle errors and maintain type safety?

A. Return Observable and use catchError to map errors to a default User instance.

B. Return Observable and use catchError to throw an ApplicationError with a user-friendly message.

C. Return Observable and use catchError to return null for any error.

D. Return Observable and rely on the global ErrorHandler to log and rethrow the error. Correct: B - Return Observable and use catchError to throw an ApplicationError with a user-friendly message.

Rationale: Using catchError to transform the error into an ApplicationError with a user-friendly message maintains type safety (the observable still emits User) and provides meaningful feedback to the UI. Returning a default User masks the error, returning null loses the error context, and rethrowing without handling defeats the purpose of catching.