Chapter 2 Flashcards
in a program are used to store data such as numbers and letters. They can be thought of as containers of a sort. The number, letter, or other data
Variabels
To know the name of the variable, how much computer memory to reserve for the variable, and how the data item in the variable is to be coded as strings of 0s and 1s. You give this information in
variable declaration
The variable can hold whole numbers, such as 42, −99, 0, and 2001. A whole number is called
Integer
What is a data type for objects of a class called?
class type
How many primitive type do we have ?
8
Which Primitive Type has the range of -128 to 127
byte
Which Primitive Type has the range of -32,768 to 32,767 ?
short
Which Primitive Type has the range of -2,147,483,648 to 2,147,483,647
int
Which Primitive Type has the range of -9,223,372,036,8547,75,808 to 9,223,372,036,854,775,807
Long
What kind of value is char?
Single character (Unicode)
What kind of value is float?
floating-point
How much memory does boolean use?
1 bit
Which Primitive Type has the range of ±3.40282347 × 10 +38 to ±1.40239846 × 10 −45
Float
Which Primitive Type has the range of ±1.79769313486231570 × 10 +308 to ±4.94065645841246544 × 10 −324
double
Which Primitive Type has the range of 0 to 65,535
char
How many floating point do we have?
2
A number having a fractional part—such as the numbers 9.99, 3.14159, −5.63, and 5.0—is called
floating-point number
As with integer types, the differences between float and double involve the range of their values and their storage requirements. If you cannot decide between the types float and double, use
double
Are these legal identifier? inputStream, YourClass, CarWash, hotCar, theTimeOfDay
yes
We will always follow the convention that the names of classes start with
Upper case letter
the names of variables and methods start with
lower case letter
Are these legal identifier prenhall.com, go-team, Five*, 7eleven ?
No
What is wrong with this identifier prenhall.com ?
It has a dot in it
What is wrong with this identifier go-team ?
It has a hyphen in it
What is wrong with this identifier Five* ?
it has an asterisk in it
What is wrong with this identifier 7eleven ?
it starts with a digit
Some words in a Java program, such as the primitive types and the word if, are called
keywords or reserved words
All Java keywords are entirely in what case?
lower case
main and println are not keywords, then what are they?
predefined meaning
What does predefined meaning mean?
you can change their meaning, but it is a bad idea to do so
The most straightforward way to give a variable a value or to change its value is to use
assignment statement
What does the “ = “ equal sign called?
assignment operator
The computer evaluates what side of the “ = “ sign in an expression, right or left?
right
A variable that has been declared, but that has not yet been given a value by an assignment statement called
uninitialized
If the variable is a variable of a class type, it literally has no value. If the variable has a primitive type, it likely has some
default value
This line must appear before the first statement that takes input from the keyboard. That statement in our example is
Scanner keyboard = new Scanner(System.in);
What does this line do keyboard.nextInt() ?
reads one int value from the keyboard.
System is a ____ that is part of the Java language, and out is ___
class, object
What does this called 865000000.0. in a Floating-point?
scientific notation
what is it public static final double PI = 3.14159; called?
Constants
You can assign a value of any type on the following list to a variable of any type that appears further down on the list called:
byte → short → int → long → float → double
Assignment Compatibilities
a _____ changes the data type of a value from its normal type to some other type.
type casting
What are the 5 Arithmetic Operators?
+ - / * and %
A __ has two operands, such as the operators + and * in
binary operator
A string can even have zero characters. Such a string is called
empty string and is written as a pair of adjacent double quotes, like so:” “.
You can connect or join or paste two strings together to obtain a larger string using +, called:
concatenation
Any characters that are not visible when displayed are collectively known as
whitespace
What is this "Java" called?
Escape Characters
" Double quote. ' Single quote. \ Backslash.
\n New line. Go to the beginning of the next line.
\r Carriage return. Go to the beginning of the current line. \t Tab. Add whitespace up to the next tab stop. are example of ?
Escape Characters
A method works like the print method except it allows you to add formatting instructions that specify things such as the number of digits to include after a decimal point.
printf
This is called /** ?
javadoc
This is called /* */ ?
long comment