Java Reference
In-Depth Information
11. Typically constructors are the only methods that you include when you define your
own exception class.
13. The answer to this exercise is available with the Additional Student Files at
www.cengagebrain.com.
15.
public class
Test
{
public static void
main(String[] args)
{
int
i = 8;
try
{
if
(i < 5)
throw new
TornadoException();
else
throw new
TornadoException(i);
}
catch
(TornadoException e)
{
System.out.println(e.getMessage());
}
}
}
17. A method specifies the exceptions it throws in its heading using the
throws
clause.
19. Any class can implement an interface. The three different options are to use an
inner class, an anonymous inner class, or the application (the applet) program class
itself to implement an interface.
Chapter 12
1. a. True; b. True; c. True; d. False; e. False; f. False; g. True; h. False; i. False
3.
JTextField
and
JTextArea
5. Sometimes you want the user to select from a set of predefined values. In addition
to freeing the user from typing in such values, to get a precise input, you want the
user to select a value from a set of given values.
7. The answer to this exercise is available with the Additional Student Files at
www.cengagebrain.com.
Search WWH ::
Custom Search