+ 2

Overriding class attributes

is there a way to override class attributes? For example: if you have a parent class 'Book', and you had a subclass 'eBook' that extends Book. Now, let's say Book has nPages for the amount of pages in the physical book. ebook however has fileSize in place of physical pages. Is it possible to override the parent attribute and replace it with the subclass version? I've been hiding the unused attributes when calling the superclass as the workaround. Thanks in advance!

29th Oct 2017, 9:07 AM
Sapphire
2 Answers
+ 2
ahhh, gotcha. So my issue was simply a problem with abstraction and trying to force a paper attribute, and create a workaround for other classes that depend on the book superclass. Thanks for your input. I thought it was a java issue that I wasn't familiar with.
29th Oct 2017, 9:43 AM
Sapphire