Data Types, Variables, & Expressions Flashcards
What is a primitive data type in Java?
It specifies the size and type of variable values and has no additional methods.
What are the most commonly used numeric types in Java?
- int (for whole numbers)
- double (for floating-point numbers).
What are the integer types available in Java?
- Byte
- Short
- Int
- Long
What are the floating-point types available in Java?
- Float
- Double
How should you indicate a long value in Java?
You should end the value with an “L”.
How should you indicate a float value in Java?
End the value with an “f”.
How should you indicate a double value in Java?
End the value with a “d”.
How can a floating-point number be expressed in scientific notation in Java?
Use an “e” to indicate the power of 10.
What values can the boolean data type in Java take?
The boolean data type can only take the values true or false.
What are boolean values mostly used for in Java?
Boolean values are mostly used for conditional testing.
What is the purpose of the char data type in Java?
The char data type is used to store a single character.
How should a character be enclosed in Java?
The character must be surrounded by single quotes, like ‘A’ or ‘c’.
What is the String data type used for in Java?
The String data type is used to store a sequence of characters (text).
How should String values be enclosed in Java?
String values must be surrounded by double quotes.
Why is String considered a non-primitive data type in Java?
Because String refers to an object.