Mastering Java: The Ultimate 2025 All-In-One Quiz to Excel in 'Thinking in Java

Question: 1 / 510

What is a drawback of using reflection in Java?

It can only call public methods

It is slower than direct method calls

Reflection allows for the inspection and manipulation of code at runtime, which can be useful in some cases. However, it comes with a performance cost as it involves additional layers of abstraction and dynamic method lookups. Therefore, option B is correct as it states that a drawback of using reflection in Java is that it is slower than direct method calls. While option A, C, and D are incorrect because they do not identify a drawback of using reflection in Java. Option A is incorrect because reflection can actually access and call both public and private methods. Option C is incorrect because reflection does have the ability to access and modify private fields, although it requires additional permissions. Finally, option D is also incorrect as reflection is still supported in modern Java versions, although there are other alternatives that may be preferred in certain situations.

Get further explanation with Examzify DeepDiveBeta

It cannot access private fields

It is not supported in modern Java versions

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy