Java Reference
In-Depth Information
catch (NumberFormatException Error) {
empPRTF.setText("");
inputError = true ;
resultLbl.setForeground(Color.red);
resultLbl.setText("Pay rate must be a " +
"numeric value: 1, 2, 3...");
}
catch (InvalidValue e) {
inputError = true ;
empPRTF.setText("");
resultLbl.setForeground(Color.red);
resultLbl.setText(e.getMessage());
}
}
Review Questions
1.
What are formatters?
What is the difference between the String and StringBuffer classes?
2.
What is the purpose of the try and catch keywords and how do they work together? How
does an exception object fit in with these two keywords?
3.
Describe the function of the Choice class.
4.
5.
What are the three primary types of iteration and what are their differences?
6.
What is method overloading, and why would a programmer use method overloading?
What are the functions of the break and continue keywords?
7.
Review Exercise
In this exercise, you will create six new classes that are subclasses of the Choice class. These new classes will display
the current date and time and will replace the EnterShipInfo frame's date and time text fields. You will also create a
new method to retrieve the information from the frame, verify that information has been supplied for all fields, and
then populate a Shipment object.
1.
In the ReviewEx/src, create a new package called c7.
2.
Copy all the classes from c6 into c7
3.
From Tutorials/src/c7, copy the Java files EnterEmpInfo and Employee into ReviewEx/src/c7.
We want to replace the older versions copied from c6 in step 2, so click Yes To All when the system prompts you
with an overwrite message.
4.
Create three new visual Java classes that are subclasses of the AWT Choice class called
MonthCh, DayCh, and YearCh.
5.
In MonthCh's initialize method:
6.
Set the size to 44, 21
 
Search WWH ::




Custom Search