Java Reference
In-Depth Information
figure 2.21
Complications caused
by the finally block.
public static void foo( )
{
try
{
return 0;
}
finally
{
return 1;
}
}
public static void bar( )
{
try
{
throw new NullPointerException( );
}
finally
{
throw new ArithmeticException( );
}
}
List the basic operations that can be performed on String s.
2.5
Explain the role of next and hasNext in the Scanner type.
2.6
IN THEORY
2.7
If x and y have the values of 5 and 7, respectively, what is output by
the following?
System.out.println( x + ' ' + y );
System.out.println( x + " " + y );
The finally block introduces complications in the Java language
specification. Write a program to determine what value is returned by
foo and what exception is thrown by bar in Figure 2.21.
2.8
IN PRACTICE
2.9
A checksum is the 32-bit integer that is the sum of the Unicode char-
acters in a file (we allow silent overflow, but silent overflow is
unlikely if all the characters are ASCII). Two identical files have the
same checksum. Write a program to compute the checksum of a file
that is supplied as a command-line argument.
Search WWH ::




Custom Search