About Question enthuware.ocpjp.v21.2.4038 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
nkaragulov
Posts: 19
Joined: Mon Sep 16, 2024 1:49 am
Contact:

About Question enthuware.ocpjp.v21.2.4038 :

Post by nkaragulov »

Does it mean constructor is allowed to change the value of the fields?
I checked it and confirm that it is indeed.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v21.2.4038 :

Post by admin »

No, nobody can change the value of the fields of a record. See this part of the explanation:
Remember that at the end of the compact record constructor, the compiler adds code that sets all the fields to the values passed in the constructor. So, if the constructor changes the passed value (as is being done in the case of the subjects variable), the updated value will be given to the subjects field of the record instance.
So, the constructor is not really changing the value of the fields. It is changing the value of the input parameters.

nkaragulov
Posts: 19
Joined: Mon Sep 16, 2024 1:49 am
Contact:

Re: About Question enthuware.ocpjp.v21.2.4038 :

Post by nkaragulov »

admin wrote:
Sat Jun 14, 2025 9:39 am
No, nobody can change the value of the fields of a record. See this part of the explanation:
Remember that at the end of the compact record constructor, the compiler adds code that sets all the fields to the values passed in the constructor. So, if the constructor changes the passed value (as is being done in the case of the subjects variable), the updated value will be given to the subjects field of the record instance.
So, the constructor is not really changing the value of the fields. It is changing the value of the input parameters.
and it follows that those parameter values are set to fields at the end. seems now I get it. thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests