Question about super() in Build a Library challenge

Hello everyone,

I have a question about the super key in the Build a Library Challenge specifically. I have looked online to find the answer but that’s where I realised that the question only pertains to that challenge.

When calling the constructor method of Media, why is there only title that gets entered as a parameter? I initially had written super(title, isCheckedOut, ratings) which returned an error. I figured out that isCheckedOut and ratings weren’t supposed to be in there but I don’t understand why.

If anyone could explain… Thanks a bunch!

Hey there. I’m not sure if you’ve found your solution to this but if in the Media class all you have defined is title, then assumedly you will return an error when passing more than 1 value to the super method. The super method is being used to call up to the parent class and apply any constructor values for the child class using that parent classes constructor(s).

That’s what I thought, but the solution only had title as a parameter and having all three returned an error.

Right that’s because the super() is calling down the constructors from the parent. If there are more values passed into the super than the parent has initialized, it will return an error.

1 Like