Skip to main content

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
operator package parameter
primitive data type pseudocode qualified name
semantics statement stepwise refinement

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 int, boolean, and double types.

  • 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 int(5).

  • 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 int values (7 + 8), the \(+\) operation produces an int result.

  • 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 class followed by an identifier naming the class followed, optionally, by the keyword extends and 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 new operator 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 System.out object.

  • A Java application program runs in stand-alone mode.

  • A Java source program must be stored in a file that has a .java extension. A Java bytecode file has the same name as the source file but a .class extension. 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).

Solutions 1.8.3 Solutions to Self-Study Exercises

1.5 Java Language Elements
1.5.7 Expressions and Operators

Self-Study Exercises Fill-In, Assignment statements. Fill-In, Assignment statements.

1.7 From the Java Library: System and PrintStream

Self-Study Exercises
You have attempted of activities on this page.