Chapter 1 Flashcards
Java identifier
A sequence of letters, digits, underscores, and dollar signs that must begin with either a letter or an underscore.
keywords in Java
Certain identifiers reserved by Java
Variable
Represents a memory location that contains a value of a primitive data type or a reference.
How to declare a variable’s data type
You declare a variable’s data type by preceding the variable name with the data type, as in
double radius;
String name;
What are the four categories of primitive data types in Java?
- Boolean
- Character
- Integer
- Floating Point
Integral Types
Character and integer types (primitive types, that is)
Arithmetic types
Integral and floating point types
Integer values
These are signed and allow numbers such as -5 and +98.
Floating-point Types
These provide for real numbers that have both an integer portion and a fractional portion.
Wrapper class
Everything in Java is an object, except primitive data types. As a solution to this problem, Java allows you to include the primitives in the family of objects by using what are called wrapper classes.
Autoboxing
Makes it easier to convert from a primitive type to their equivalent wrapper class counterparts.
Integer intObject = 9;
Auto-unboxing
The reverse process of converting an object of one of the wrapper classes into a value of the corresponding primitive type.
References in Java
Java has one other type that is used to locate an object. This reference variable contains an object’s location in memory.
Literal constants
Indicate particular values within a program.
4 * Math.PI * radiusCubed / 3
(4 & 3 are literal constants)
Backslash notation
This notation is useful when you want to embed one of these characters within a literal character string.