Exam 2 Flashcards
(87 cards)
Every value in Java is either:
A reference to an ________
One of the _____________ types
Object
Primitive
Java has ___ primitive types
8
Java’s primitive types are:
Four ___________
Two _________
Two _________
Integer types
Floating point types
Others
Range +- 2,147,483,648 with 4 bytes
Int
Range -128…127
Byte
Integer type, with range -32768…32767 with 2 bytes
Short
Integer type, with range +- 9,223,372,036,854,775,808 with 8 bytes
Long
Floating point type, range +- 10^308 with about 15 significant decimal digits with 8 bytes
Double
Single precision floating point type with a range of about +- 10^38 and about 7 significant decimal digits with 4 bytes
Float
Representing code units in the Unicode encoding scheme with 2 bytes
Char
Type with the two truth values false and true with 1 bit
Boolean
If it is a decimal, it is a:
Floating-point number
If it is not a decimal, then it is a:
Integer
Generally, you use ______ for integers
Int
The result of a computation exceeds the range for the number type
Overflow
Occur when and exact representation of a floating point number is not possible
Rounding errors
Floating point numbers have _________ precision.
Limited
You should use _______ type in most cases
Double
A final variable is a:
Constant
Once a Constant is set, it ________ be changed.
Cannot
Use all uppercase names for constants
Convention
The static reserved word means that the constant _________________, not the object
Belongs to the class
Give _____________ constants public access to enable other classes to use them
Static final
What’s the difference between the following two statements?
final double CM_PER_INCH = 2.54;
public static final double CM_PER_INCH = 2.54;
The first declaration is used inside a method
The second declaration is used inside a class