[HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

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

Moderator: admin

Post Reply
joaoclopes
Posts: 16
Joined: Mon Sep 23, 2024 4:49 pm
Contact:

[HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Post by joaoclopes »

Hello, in this example shouldn't we mention that it will never compile because Person class doesn't have no args constructor?

Thanks!

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

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Post by admin »

Right but if constructors were inherited, the Employee class would have inherited the String argument constructor from Person and the given code would have compiled. There would not have been a need for the no-args constructor in Person.
If you like our products and services, please help us by posting your review here.

joaoclopes
Posts: 16
Joined: Mon Sep 23, 2024 4:49 pm
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 13.1.2 - inheriting-constructors-and-initializers]

Post by joaoclopes »

Got it! It was just to explain that constructors aren't inherited.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests