I have an abstract super class called Document
and two child classes called Magazine
and Book
. What is the difference between :
Document book = new Book();
and Book book = new Book();
Thank you in advance.
I have an abstract super class called Document
and two child classes called Magazine
and Book
. What is the difference between :
Document book = new Book();
and Book book = new Book();
Thank you in advance.
The difference is for example if you have any information about document only in the document class, like, say, price. By doing
you won't be able to get the price of the book, so doing
will give you additional information about your object. Note that price is not the best example. I only wanted to show you how the super-/subclass work.