Statement I is incorrect because the super class that will be inherited does not contain any parameters. You know this because super(); contains nothing within the parenthesis (no parameters). However, the Hen class has the parameter(String species).
Statement II is the only correct statement because it contains super which allows the class to be inherited, and it contains the parameter inside the inherited class which is a string value, "species".
Statement III is incorrect because mySpecies = species is simply the Bird class' constructor which is a private instance variable, therefore making it impossible to reach.
Let's check out:
ReplyDelete"Statement II is the only correct statement because it contains super which allows the class to be inherited, and it contains the parameter inside the inherited class which is a string value, "species"."
The use of super doesn't allow for inheritance. It utilizes the possibilities of inheritance brought about by this:
public class Owl extends Bird
The "extends" keyword establishes the "is-a" relationship, the inheritance is engaged there.
Otherwise, we're good here. 100 XPs for completion.
thank you for the insight and a more in depth explanation of inheritance. I completely understand
ReplyDelete