Java Reference
In-Depth Information
34.
There are two types of import statements: specific import and wildcard import. The
specific import specifies a single class in the import statement; the wildcard import
imports all the classes in a package.
35.
Programming errors can be categorized into three types: syntax errors , runtime errors ,
and logic errors. Errors that occur during compilation are called syntax errors or
compile errors. Runtime errors are errors that cause a program to terminate abnor-
mally. Logic errors occur when a program does not perform the way it was intended to.
T EST Q UESTIONS
Do the test questions for this chapter online at www.cs.armstrong.edu/liang/intro9e/test.html .
P ROGRAMMING E XERCISES
Note
Solutions to even-numbered exercises are on the Companion Website. Solutions to
all exercises are on the Instructor Resource Website. The level of difficulty is rated
easy (no star), moderate ( * ), hard ( ** ), or challenging ( *** ).
level of difficulty
1.1
( Display three messages ) Write a program that displays Welcome to Java ,
Welcome to Computer Science , and Programming is fun .
1.2
( Display five messages ) Write a program that displays Welcome to Java five times.
* 1.3
( Display a pattern ) Write a program that displays the following pattern:
J A V V A
J A A V V A A
J J AAAAA V V AAAAA
J J A A V A A
1.4
( Print a table ) Write a program that displays the following table:
a a^2 a^3
1 1 1
2 4 8
3 9 27
4 16 64
1.5
( Compute expressions ) Write a program that displays the result of
9.5
*
4.5
-
2.5
*
3
.
45.5
-
3.5
1.6
( Summation of a series ) Write a program that displays the result of
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9.
1.7
( Approximate
p
)
p
can be computed using the following formula:
1
3 +
1
5 -
1
7 +
1
9 -
1
11 + c
p =
4
* ¢
1
-
1
3 +
1
5 -
1
7 +
1
9 -
1
11
Write a program that displays the result of
4
* ¢
1
-
1
3 +
1
5 -
1
7 +
1
9 -
1
11 +
1
13
and
4
* ¢
1
-
.
Use 1.0 instead of 1 in your
program.
 
Search WWH ::




Custom Search