In Java, reflection provides what capability at runtime?

Prepare for the Object-Oriented Programming Test with flashcards and multiple choice questions. Each question comes with hints and explanations to enhance understanding. Master OOP concepts and succeed in your exam!

Multiple Choice

In Java, reflection provides what capability at runtime?

Explanation:
Reflection in Java provides a runtime capability to inspect and interact with a program’s own structure. At runtime, you can query a class about its methods, fields, constructors, and annotations, create instances, and invoke methods or access fields, even if they’re private (within security and access rules). This enables frameworks and tools to adapt to types they discover during execution, support dynamic object creation from configuration, and implement features like serialization or dependency injection. The other options describe tasks that happen at compile time or are managed by the JVM for memory and optimization, not something you perform with reflection at runtime.

Reflection in Java provides a runtime capability to inspect and interact with a program’s own structure. At runtime, you can query a class about its methods, fields, constructors, and annotations, create instances, and invoke methods or access fields, even if they’re private (within security and access rules). This enables frameworks and tools to adapt to types they discover during execution, support dynamic object creation from configuration, and implement features like serialization or dependency injection. The other options describe tasks that happen at compile time or are managed by the JVM for memory and optimization, not something you perform with reflection at runtime.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy