What is a variable in Java?
A variable represents a value stored in computer memory. It has a name, type, and value.
What are the 6 numeric data types in Java?
byte, short, int, long, float, double
What is the range of byte data type?
-128 to 127 (8-bit signed)
What is the range of short data type?
-32768 to 32767 (16-bit signed)
What is the range of int data type?
-2147483648 to 2147483647 (32-bit signed)
What is the storage size of long data type?
64-bit signed
What is the storage size of float data type?
32-bit IEEE 754
What is the storage size of double data type?
64-bit IEEE 754
How many significant digits does float have?
6-9 significant digits
How many significant digits does double have?
15-17 significant digits
What is the syntax for declaring a variable?
datatype variableName;
What is the syntax for declaring and initializing a variable?
datatype variableName = value;
Can you declare multiple variables of the same type in one line?
Yes: datatype variable1, variable2, variable3;
What keyword is used to declare constants in Java?
final
What is the syntax for declaring a constant?
final datatype CONSTANTNAME = value;
What are 3 benefits of using constants?
1) No repeated typing of same value 2) Easy to change in one location 3) Makes code more readable
How do you import the Scanner class?
import java.util.Scanner;
How do you create a Scanner object?
Scanner input = new Scanner(System.in);
What method reads a double from keyboard?
input.nextDouble()
What method reads an int from keyboard?
input.nextInt()
What method reads a byte from keyboard?
input.nextByte()
What method reads a short from keyboard?
input.nextShort()
What method reads a long from keyboard?
input.nextLong()
What method reads a float from keyboard?
input.nextFloat()