Section 1.8 Chapter Summary
Subsection 1.8.1 Technical Terms
|application program||assignment statement||comment|
|compound statement (block)||data type||declaration statement|
|default constructor||executable statement||expression|
|identifier||literal value||object instantiation|
|primitive data type||pseudocode||qualified name|
Subsection 1.8.2 Summary of Important Points
Good program design requires that each object and method have a well-defined role and clear definition of what information is needed for the task and what results will be produced.
Good program design is important; the sooner you start coding, the longer the program will take to finish. Good program design strives for readability, clarity, and flexibility.
Testing a program is very important and must be done with care, but it can only reveal the presence of bugs, not their absence.
An algorithm is a step-by-step process that solves some problem. Algorithms are often described in pseudocode, a hybrid language that combines English and programming language constructs.
A syntax error occurs when a statement breaks a Java syntax rules. Syntax errors are detected by the compiler. A semantic error is an error in the program's design and cannot be detected by the compiler.
Writing Java code should follow the stepwise refinement process.
Double slashes (//) are used to make a single-line comment. Comments that extend over several lines must begin with /* and end with */.
An identifier must begin with a letter of the alphabet and may consist of any number of letters, digits, and the special characters _ and $. An identifier cannot be identical to a Java keyword. Identifiers are case sensitive.
A keyword is a term that has special meaning in the Java language (Table 1.5.5).
Examples of Java's primitive data types include the
A variable is a named storage location. In Java, a variable must be declared before it can be used.
A literal value is an actual value of some type, such as a
String("Hello") or an
A declaration statement has the form:
Type VariableName ;
An assignment statement has the form:
VariableName = Expression ;
When it is executed it determines the value of the Expression on the right of the assignment operator (\(=\)) and stores the value in the variable named on the left.
Java's operators are type dependent, where the type is dependent on the data being manipulated. When adding two
7 + 8), the \(+\) operation produces an
A class definition has two parts: a class header and a class body. A class header takes the form of optional modifiers followed by the word
classfollowed by an identifier naming the class followed, optionally, by the keyword
extendsand the name of the class's superclass.
There are generally two kinds of elements declared and defined in the class body: variables and methods.
Object instantiation is the process of creating an instance of a class using the
newoperator in conjunction with one of the class's constructors.
Dot notation takes the form qualifiers.elementName. The expression
System.out.print("hello")uses Java dot notation to invoke the
print()method of the
A Java application program runs in stand-alone mode.
A Java source program must be stored in a file that has a
.javaextension. A Java bytecode file has the same name as the source file but a
.classextension. It is an error in Java if the name of the source file is not identical to the name of the public Java class defined within the file.
Java programs are first compiled into bytecode and then interpreted by the Java Virtual Machine (JVM).