[HD Pg 213, Sec. 8.5.3 - constructor-chaining]

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

Moderator: admin

Post Reply
enthunoob
Posts: 60
Joined: Thu Apr 15, 2021 12:21 pm
Contact:

[HD Pg 213, Sec. 8.5.3 - constructor-chaining]

Post by enthunoob »

"It is in fact against the rules to try to invoke another constructor using the constructor name and it will result in a compilation error."

I think what is meant here is:

"It is in fact against the rules to try to invoke another constructor using the constructor name and parameters, as in with the same ammount of parameters as where the other constructor is being called from, and it will result in a compilation error."

Right?

enthunoob
Posts: 60
Joined: Thu Apr 15, 2021 12:21 pm
Contact:

Re: [HD Pg 213, Sec. 8.5.3 - constructor-chaining]

Post by enthunoob »

Oh I see, after reading it a 4th time. It's about the word this.

When calling a constructor from another constructor, you always have to call it with the word 'this' (and it's illegal to use the classes name when chaining another constructor). Got it.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 34 guests