15.6 Exercises


15.6 Exercises

  1. Explain the purpose of using exceptions in any program. If a program can be implemented without exceptions, what are the trade-offs?

  2. Explain the differences between throwing an exception and catching an exception. Give examples.

  3. What is the difference between detecting an exception and throwing an exception? Explain and give examples. Why do most Java classes for input/output throw exceptions?

  4. Redesign and reimplement class Fileproc by adding exception handling for an empty name and age less than 18.

  5. Redesign and reimplement class Fileproc. The new class must declare and create an array of objects of class Employeec and compute the lowest, highest, and average salary.

  6. Design and implement a program with at least two classes that stores the inventory parts for a warehouse. Each inventory part has the following attributes: description, unit code, number of items in stock, and the unit cost. The program should store the data in a text file. The program should also compute the total investment per item.

  7. Design and implement a program with at least two classes that reads the inventory data from the text file written by the program in the previous exercise. The program should display the individual data on each inventory item, and print the total investment and revenue.

  8. Redesign and reimplement the program in the previous exercise by adding exception handling for a negative number of parts in stock, a zero or negative unit cost, and negative unit price.

  9. Redesign and reimplement the program in the previous exercise by adding exception handling for a unit price equal to or less than the unit cost.

  10. Design and implement a GUI for inventory data in the inventory program in Exercise 6.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net