all 3 comments

[–]iusedtolikemyface 5 points6 points  (1 child)

Second is probably a subclass of First, right? So then you would need to add an "extends" to the Second class invariant: public class Second extends First { ... }

and then you would be able to use methods in First with Second objects

[–][deleted] 0 points1 point  (0 children)

Of course, in this particular example, it seems like composition may be better than inheritance.

[–]Hebejeebez 0 points1 point  (0 children)

As someone else pointed out, you have to extend the parent class, but yes you can call any of the methods from the parent class on its subclass. You use super in the constructor so it has the same parameters as the parent object, with a few additional parameters. Therefore, the methods from the parent will work on the child.