Objective Assessment Review
(Questions & Solutions)
2025
©2025
,1. Question 1
Which of the following best describes the behavior of a final reference
variable in Java?
A. The variable remains null and cannot be assigned any value.
B. The variable must be assigned exactly once; the reference cannot
be changed, though the referenced object’s state may be mutable.
C. The referenced object becomes completely immutable.
D. The variable is automatically thread-safe.
ANS: B
Rationale: Declaring a reference variable as final ensures the variable
can be assigned only once. However, if the object it refers to is mutable,
its internal state can still be changed. This distinction is critical in
differentiating between reference immutability and object immutability.
2. Question 2
What is the primary purpose of Java’s garbage collection mechanism?
A. To automatically reclaim memory by freeing objects that are no
longer reachable.
B. To explicitly deallocate memory with a finalize method.
C. To optimize CPU usage by managing threads.
D. To convert Java source code into platform-specific binaries.
ANS: A
Rationale: Garbage collection in Java automatically identifies and
clears objects that are no longer reachable, thereby reclaiming memory
and improving application stability without manual intervention.
3. Question 3
Which statement best describes method overloading versus method
overriding in Java?
A. Overloading is runtime polymorphism, whereas overriding is
compile‑time polymorphism.
B. Overloading involves multiple methods in the same class with the
same name but different parameter lists; overriding allows a subclass to
©2025
,provide a specific implementation for a method in its superclass.
C. Overloading applies only to static methods, while overriding
applies only to instance methods.
D. There is no difference; both terms refer to redefining methods.
ANS: B
Rationale: Overloading and overriding are distinct mechanisms.
Overloading is resolved at compile time using different parameter lists,
while overriding is a runtime feature enabling a subclass to refine or
change the behavior of a superclass method.
4. Question 4
Regarding Java generics and type erasure, which statement is correct?
A. Generic type information is fully retained at runtime for reflection
purposes.
B. Generics enforce bounds at runtime while erasing type information
at compile time.
C. Type erasure removes generic type information completely at
compile time, so runtime operations cannot reflect on the generic type.
D. Generics provide additional runtime type checking to enforce type
constraints.
ANS: C
Rationale: Java implements generics using type erasure, meaning all
generic type information is removed during compilation. As a result,
runtime reflection cannot directly access the generic parameter types;
only the information enforced by the compiler remains.
5. Question 5
What is the primary advantage of using lambda expressions in Java?
A. They provide a concise syntax for implementing functional
interfaces.
B. They allow method overloading based on lambda signatures.
C. They automatically parallelize code execution.
D. They eliminate the need for anonymous inner classes in all
scenarios.
ANS: A
©2025
, Rationale: Lambda expressions, introduced in Java 8, offer a compact
syntax to implement interfaces with a single abstract method (functional
interfaces), thereby reducing boilerplate code and enhancing readability.
6. Question 6
What is the primary function of the `volatile` keyword in Java?
A. It automatically synchronizes a variable across threads, ensuring
full thread safety.
B. It guarantees atomicity for compound operations.
C. It ensures that reads and writes to a variable are directly written to
and read from main memory.
D. It instructs the garbage collector to reclaim the variable’s memory
more promptly.
ANS: C
Rationale: Declaring a variable as volatile ensures that its value is
always read from main memory, thus providing visibility of its latest value
to all threads. It does not, however, guarantee atomicity of compound
actions.
7. Question 7
Which design pattern is implemented by ensuring that a class has only
one instance and provides a global point of access to it?
A. Factory Pattern
B. Singleton Pattern
C. Observer Pattern
D. Builder Pattern
ANS: B
Rationale: The Singleton Pattern restricts the instantiation of a class
to a single object, ensuring controlled access and a global point of access
to that instance.
8. Question 8
Which best describes Java Reflection?
A. A mechanism that enables inspection and modification of classes,
methods, and fields at runtime.
©2025