Chapter 2 PDF Flashcards
What is the typical program structure
Input some data
Perform some processing on the data
Output the results
Describe what could happen in each execution of the program
The data might be different
Instructions will be the same
What do all Java Application programs consist of
All programs consist of at least one class
What are identifiers used to name
Classes, variables and methods
What are some identifier rules
Must start with a Java Letter
Can contain essentially any number of java letters and digits but no spaces
Case sensitive
Cannot be keywords or reserved words
Is this identifier valid: taxRate
yes
Is this identifier valid: char
No. Char is a keyword
Is this identifier valid: intNumber
Yes, the keyword int is embedded but the identifier is not identical to a keyword
Is this identifier valid: 2008Taxrate
No. The identifier starts with a digit
Describe the statement in a program building block
Performs some action
Terminates with a semicolon;
Can span multiple lines
Describe the block in the program building block
0,1, or more statements
begins and ends with curly braces {}
Can be used anywhere a statement is allowed
What are white space characters. Describe them
- Space, tab, and newline are white space characters.
- At least one white space character is required between a keyword and identifier.
- Any number of white space characters are permitted between identifiers, keywords, operators, and literals.
What are comments used for
Comments explain the program to yourself and others.
How do you comment a line
Begin with /* and end with */
What is a requirement for all data
That you assign a name and a data type
What is the purpose of a data type
How much memory to allocate
How to store the data
The types of operations you will perform on the data
What are the eight primitive data types
byte short int long float double char boolean
How many values can a variable hold
Variables hold one value at a time, but the value can change as the program executes
Describe the naming convention for variable names
First letter is lowercase
Embedded words begin with an uppercase letter
What are boolean values used for
Boolean values are used for decision making or as flag variables
Describe what putting an assignment operator does to variables
Value on the right of the operator is assigned to variable on the left
What can the variable on the right be
A literal, another variable, or an expression