-3

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.

Dwix
  • 1,139
  • 3
  • 20
  • 45

1 Answers1

0

The difference is for example if you have any information about document only in the document class, like, say, price. By doing

Book book = new Book();

you won't be able to get the price of the book, so doing

Document book = new Book();

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.

Arthur Eirich
  • 3,368
  • 9
  • 31
  • 63