Java Reference
In-Depth Information
The Java language has a syntax, or a legal set of com-
mands that can be used. A Java program that does not fol-
low the proper syntax will not compile. A program that
does compile but that is written incorrectly may still con-
tain errors called exceptions that occur when the program
runs. A third kind of error is a logic or intent error. This
kind of error occurs when the program runs but does not
do what the programmer intended.
reusable pieces. An important static method that must be
part of every program is called main .
Iterative enhancement is the process of building a program
piece by piece, testing the program at each step before
advancing to the next.
Complex programming tasks should be broken down into
the major tasks the computer must perform. This process
is called procedural decomposition. Correct use of static
methods aids procedural decomposition.
Commands in programs are called statements. A class can
group statements into larger commands called static meth-
ods. Static methods help the programmer group code into
Self-Check Problems
Section 1.1: Basic Computing Concepts
1. Why do computers use binary numbers?
2. Convert each of the following decimal numbers into its equivalent binary number:
a. 6
b. 44
c. 72
d. 131
3. What is the decimal equivalent of each of the following binary numbers?
a. 100
b. 1011
c. 101010
d. 1001110
4. In your own words, describe an algorithm for baking cookies. Assume that you have a large number of hungry
friends, so you'll want to produce several batches of cookies!
5. What is the difference between the file MyProgram.java and the file MyProgram.class ?
Section 1.2: And Now—Java
6. Which of the following can be used in a Java program as identifiers?
println first-name AnnualSalary "hello" ABC
42isTheAnswer for sum_of_data _average B4
7. What is the output produced from the following statements?
System.out.println("\"Quotes\"");
System.out.println("Slashes \\//");
System.out.println("How '\"confounding' \"\\\" it is!");
 
 
Search WWH ::




Custom Search