← Back to libraryQuestion 52 of 273
JavaAdvanced

Reflection in Java

📖 Detailed Explanation:

Reflection allows code to inspect and manipulate classes, methods, fields at runtime. Examples: getting method info via Class.getMethod(), invoking methods dynamically, accessing private fields. Used heavily by frameworks (Spring, Hibernate), but has performance costs and security implications.

🎯 Scenario-Based Interview Question:

How does Spring Framework use Reflection? What are the security implications?

💡 Note:

Reflection is powerful but slow. Use for frameworks and libraries, not for performance-critical code paths.