LearnFrenzy
Sign in Take a free test

Constructors and the this Keyword · Constructors MCQ · Question 18

Calling an overridable method in a constructor Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 18 Back to Exercise

Why is calling an overridable method from a constructor risky?

  • A It is a compile error
  • B A subclass override may run before the subclass's fields are initialised, so it sees default values Correct
  • C It causes infinite recursion
  • D The method cannot access fields
Correct Answer: Option B

Make such methods private or final, or avoid the call.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links