Objective Assessment Review
(Questions & Solutions)
2025
©2025
, Question 1
A Java developer declares a reference variable as `final`. Which of the
following statements is correct regarding this variable?
A. The variable’s reference can be changed at runtime, but its object
state cannot be mutated.
B. The variable can be assigned only once; however, the internal state
of the object it points to may still be mutable.
C. The object's state becomes immutable as well.
D. The variable is automatically thread‑safe against concurrent
modifications.
ANS: B
Rationale: A `final` reference means you can assign it only once. It does
not alter the mutable nature of the object it refers to—only that the
reference cannot be reseated to a different object.
---
Question 2
Which of the following is a primary benefit of introducing lambda
expressions in Java (since Java 8)?
A. They eliminate the need for all anonymous inner classes.
B. They provide a concise syntax for implementing functional interfaces
while enabling easier parallel processing for streams.
C. They enforce strict type-checking at runtime.
D. They automatically parallelize any sequential code.
ANS: B
Rationale: Lambda expressions offer concise syntax to implement
interfaces with a single abstract method (functional interfaces) and pair
naturally with the Stream API for parallel processing. They do not
eliminate all anonymous classes and do not auto-parallelize code without
explicit stream support.
©2025
, ---
Question 3
A developer is designing a high-volume server application that requires
efficient concurrent processing. Which of the following is the best
practice for managing threads in Java?
A. Spawning a new thread for each client request.
B. Using the synchronized keyword exclusively on shared methods.
C. Employing a thread pool provided by the Executor framework.
D. Running all tasks sequentially within a single thread to avoid
synchronization issues.
ANS: C
Rationale: Using a thread pool (via the Executor framework) efficiently
reuses a fixed number of threads, reducing overhead and managing
concurrency better than creating fresh threads per request.
---
Question 4
In a Java application utilizing the Stream API for large datasets, which
feature of streams allows the framework to delay computation until a
terminal operation is invoked?
A. Eager evaluation
B. Lazy evaluation
C. Immediate execution
D. Synchronous blocking
ANS: B
Rationale: Lazy evaluation is a key characteristic of Java streams:
intermediate operations are not executed until a terminal operation
triggers processing, improving efficiency and enabling short-circuiting.
---
©2025