Variables and Data Types - AP Computer Science A
Card 1 of 30
What is the size in bits of a long data type in Java?
What is the size in bits of a long data type in Java?
Tap to reveal answer
64 bits. Long provides extended range for large integer values.
64 bits. Long provides extended range for large integer values.
← Didn't Know|Knew It →
What is the size in bits of a float data type in Java?
What is the size in bits of a float data type in Java?
Tap to reveal answer
32 bits. Float uses single precision for decimal numbers.
32 bits. Float uses single precision for decimal numbers.
← Didn't Know|Knew It →
Identify the default value for a boolean variable in Java.
Identify the default value for a boolean variable in Java.
Tap to reveal answer
false. Java initializes unassigned boolean variables to false.
false. Java initializes unassigned boolean variables to false.
← Didn't Know|Knew It →
What is the default value of an int variable in Java?
What is the default value of an int variable in Java?
Tap to reveal answer
- Java initializes unassigned integer variables to zero.
- Java initializes unassigned integer variables to zero.
← Didn't Know|Knew It →
State the Java data type for a single character.
State the Java data type for a single character.
Tap to reveal answer
char. It stores a single Unicode character in 16 bits.
char. It stores a single Unicode character in 16 bits.
← Didn't Know|Knew It →
Which data type represents true or false values in Java?
Which data type represents true or false values in Java?
Tap to reveal answer
boolean. It can only hold one of two logical states.
boolean. It can only hold one of two logical states.
← Didn't Know|Knew It →
What data type in Java is used for decimal numbers?
What data type in Java is used for decimal numbers?
Tap to reveal answer
double. It provides 64-bit precision for floating-point numbers.
double. It provides 64-bit precision for floating-point numbers.
← Didn't Know|Knew It →
How do you declare a float variable named 'temperature'?
How do you declare a float variable named 'temperature'?
Tap to reveal answer
float temperature;. Float provides 32-bit precision for decimal numbers.
float temperature;. Float provides 32-bit precision for decimal numbers.
← Didn't Know|Knew It →
What is the size in bits of a boolean data type in Java?
What is the size in bits of a boolean data type in Java?
Tap to reveal answer
Not precisely defined. Implementation varies by JVM and platform.
Not precisely defined. Implementation varies by JVM and platform.
← Didn't Know|Knew It →
How do you declare a string variable named 'name'?
How do you declare a string variable named 'name'?
Tap to reveal answer
String name;. This creates a String reference variable.
String name;. This creates a String reference variable.
← Didn't Know|Knew It →
What does the '==' operator test in Java?
What does the '==' operator test in Java?
Tap to reveal answer
Equality. It compares two values for identical content.
Equality. It compares two values for identical content.
← Didn't Know|Knew It →
What is the result of '10 % 4' in Java?
What is the result of '10 % 4' in Java?
Tap to reveal answer
- Modulo returns the remainder after division.
- Modulo returns the remainder after division.
← Didn't Know|Knew It →
Identify the result of '3.0 / 2' in Java.
Identify the result of '3.0 / 2' in Java.
Tap to reveal answer
1.5. Double division produces a decimal result.
1.5. Double division produces a decimal result.
← Didn't Know|Knew It →
How do you declare a char variable named 'grade'?
How do you declare a char variable named 'grade'?
Tap to reveal answer
char grade;. This creates a character variable for single letters.
char grade;. This creates a character variable for single letters.
← Didn't Know|Knew It →
What is the default value of a double variable in Java?
What is the default value of a double variable in Java?
Tap to reveal answer
0.0. Java initializes unassigned double variables to zero.
0.0. Java initializes unassigned double variables to zero.
← Didn't Know|Knew It →
Which data type would you use for a variable storing a small integer?
Which data type would you use for a variable storing a small integer?
Tap to reveal answer
byte. Byte is the smallest integer type in Java.
byte. Byte is the smallest integer type in Java.
← Didn't Know|Knew It →
How do you declare a boolean variable named 'isOpen'?
How do you declare a boolean variable named 'isOpen'?
Tap to reveal answer
boolean isOpen;. This creates a boolean variable for true/false values.
boolean isOpen;. This creates a boolean variable for true/false values.
← Didn't Know|Knew It →
What is the maximum value of an int in Java?
What is the maximum value of an int in Java?
Tap to reveal answer
2,147,483,647. This is the upper limit for 32-bit signed integers.
2,147,483,647. This is the upper limit for 32-bit signed integers.
← Didn't Know|Knew It →
What is the size in bits of a short data type in Java?
What is the size in bits of a short data type in Java?
Tap to reveal answer
16 bits. Short provides a smaller integer range than int.
16 bits. Short provides a smaller integer range than int.
← Didn't Know|Knew It →
Which escape sequence is used for a new line in Java?
Which escape sequence is used for a new line in Java?
Tap to reveal answer
\n. It moves output to the next line.
\n. It moves output to the next line.
← Didn't Know|Knew It →
What arithmetic operator represents subtraction in Java?
What arithmetic operator represents subtraction in Java?
Tap to reveal answer
-. It performs mathematical subtraction operations.
-. It performs mathematical subtraction operations.
← Didn't Know|Knew It →
How do you declare a double variable named 'price'?
How do you declare a double variable named 'price'?
Tap to reveal answer
double price;. This creates a double-precision floating-point variable.
double price;. This creates a double-precision floating-point variable.
← Didn't Know|Knew It →
What is the Java data type for storing a real number with double precision?
What is the Java data type for storing a real number with double precision?
Tap to reveal answer
double. It offers higher precision than float for decimals.
double. It offers higher precision than float for decimals.
← Didn't Know|Knew It →
Which operator is used for concatenating strings in Java?
Which operator is used for concatenating strings in Java?
Tap to reveal answer
+. It joins string literals or variables together.
+. It joins string literals or variables together.
← Didn't Know|Knew It →
What is the result of '5 / 2' in Java using integer division?
What is the result of '5 / 2' in Java using integer division?
Tap to reveal answer
- Integer division truncates the decimal portion.
- Integer division truncates the decimal portion.
← Didn't Know|Knew It →
Identify the data type for whole numbers in Java.
Identify the data type for whole numbers in Java.
Tap to reveal answer
int. It stores integers without decimal points.
int. It stores integers without decimal points.
← Didn't Know|Knew It →
What is a variable in programming?
What is a variable in programming?
Tap to reveal answer
A variable is a named storage location for data. It holds values that can change during program execution.
A variable is a named storage location for data. It holds values that can change during program execution.
← Didn't Know|Knew It →
Which operator is used for concatenating strings in Java?
Which operator is used for concatenating strings in Java?
Tap to reveal answer
+. It joins string literals or variables together.
+. It joins string literals or variables together.
← Didn't Know|Knew It →
How do you declare a char variable named 'grade'?
How do you declare a char variable named 'grade'?
Tap to reveal answer
char grade;. This creates a character variable for single letters.
char grade;. This creates a character variable for single letters.
← Didn't Know|Knew It →
How do you declare a double variable named 'price'?
How do you declare a double variable named 'price'?
Tap to reveal answer
double price;. This creates a double-precision floating-point variable.
double price;. This creates a double-precision floating-point variable.
← Didn't Know|Knew It →