go to previous page   go to home page   go to next page
((Book)item1).display();

Answer:

Because you want to:


When is a Type Cast Needed?

Now examine the following:

public class Store
{
  public static void main ( String[] args )
  {
    Book book ;
    Taxable tax = new Book ( "Emma", 24.95, "Austen" );

    book = tax;
    book.display();
    System.out.println( "Tax on item 1 "+ book.calculateTax() );
  }
}

QUESTION 21:

Is a type cast necessary? Where should it go?