Chapter 2 Flashcards
structure
Building ideas together so that a complex program involves a simple set of smaller parts combined.
coding
would then refer to filling in
the details of that design.
syntax
The rules that determine what is allowed in a programming language. Syntax rules specify the basic vocabulary of the language and how programs can be constructed using things like loops, branches, and subroutines. A syntactically correct program is one that
can be successfully compiled or interpreted; programs that have syntax errors will be rejected
(hopefully with a useful error message that will help you fix the problem).
semantics
Ensuring that the meaning of the results is correct or follows the logical assumptions of what the answer should be.
pragmantics/style
ensuring that the design of a program visually makes sense to the user.
subroutine call statement
It uses a “built-in subroutine”
named System.out.println to do the actual work. Recall that a subroutine consists of the
instructions for performing some task, chunked together and given a name. That name can be
used to “call” the subroutine whenever that task needs to be performed.
built-in subroutine
is one that is already defined as part of the language and therefore automatically available for use in any program.
comments
Comments in a program are entirely ignored by the computer; they are there for human readers only. // or starts with /* and ends with */
class
Not every class is a program. In order to define a program, a class must include a subroutine named main, with a definition that takes the form:
public static void main(String[] args) {
{ statements }
}
public
used in the first line of main() means that the routine can be called from outside the program. This is essential because the main() routine is called by the Java interpreter,
which is something external to the program itself
where is the subroutine located in a Java program?
between { and }.
packages
A package is a group of classes.
Class and file name rules
If the name of the class is HelloWorld, then the class must be saved in a file called HelloWorld.java
identifiers
Identifiers can be used to name classes, variables, and subroutines. An identifier is a sequence of one or
more characters. It must begin with a letter or underscore and must consist entirely of letters,
digits, and underscores. No spaces are allowed in identifiers;
reserve words
words reserved for special uses in Java that can’t be used as identifiers, such as:
class, public, static, if, else, while, and several dozen other words