Skip to content
Sharp

Reflection API · interview question

What does invoking getDeclaredFields() on a class evaluate to?

Multiple choiceMediumchapter-16-curatedpremiumreflection-apibreaking-encapsulation
Choose one answer
Answer and explanation

Correct answer

B. An array of Field objects including all fields declared in the class

Why

The getDeclaredFields() method returns an array of Field objects reflecting all fields declared by the class, regardless of their access modifiers, but excluding inherited fields.

Test yourself on Reflection API

A free test with instant, explained results. No account needed.

Start free test
All Reflection API questions →