0

Any constructor must explicitly initialize all fields of a class. (Java)

Is this statement true or false? And Can someone please explain why? I do not understand the question.

0

2 Answers 2

1

This statement is false, because all the fields of a class are initialized to their default type values. A reference on an object is initialized to null, an int to 0, a double to 0.0 etc...

Sign up to request clarification or add additional context in comments.

Comments

1

First of, please try it.

To answer the question: No. A constructor does not have to initialize all fields.

After the construction of an object all final fields must be initialized.

All non-final variables have default variables in Java. Reference

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.