Chapter 8: Packages and Interfaces

1. Using the code from Try This 8-1, put the ICharQ interface and its three implementations into a package called qpack. Keeping the queue demonstration class IQDemo in the default package, show how to import and use the classes in qpack.

To put ICharQ and its implementations into the qpack package, you must separate each into its own file, make each implementation class public, and add this statement to the top of each file.

Image

Once this has been done, you can use qpack by adding this import statement to IQDemo.

2. What is a namespace? Why is it important that Java allows you to partition the namespace?

A namespace ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.