I have some sub classes and one base.
Base is movie, and I would like to call the method in the Fiction method which is sub-class.
The method will be called from other method called (management.java).
Fiction has its own field called typeOfmovie and getter and setter method.
What I’m trying to do is, I would like to call that getter or setter method.
But even if I create like:
Movie m = new Fiction();
I cannot call getter or setter method from there.
The only way is I should create abstract method in the movie class?
I could, but as the number of fields getting bigger, I thought the base class might get messy.
Is that only way I can do?
Also, the field is package private (default), but I still cannot access that way either
Can you give me an advice please?
Thanks
Your Declaration say’s m is of type movie , so it can call methods that are declared in Movie only ( if any of base class methods overridden in your subclass, then overridden method code will be executed ). But if You want to call extra methods in subclass .You have to create your object like this