((Book)item1).getAuthor()
Because you want to:
item1
to type Book
getAuthor()
method that objects of type Book
have.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; System.out.println( book ); System.out.println( "Tax on item 1 "+ book.calculateTax() ); } }
Is a type cast necessary? Where should it go?