WorksheetsJava Primitive Practice
Total questions: 20
Worksheet time: 11mins
Which of the following is not a primitive data type in Java?
Which data type is used to store whole numbers in Java?
What is the range of the int data type in Java?
-2,648 to 2,647
Which data type is used to store characters in Java?
Which of the following is a proper way to declare a variable in Java?
myInteger = 100;
char = 'a';
int myNumber = 10;
int myNumber;
Which of the following is a proper way to declare and initialize a variable in Java?
myInteger = 100;
char = 'a';
int myNumber = 10;
int myNumber;
Which of the following variable names follows best practices for naming a variable?
5apples
someVariable
applesnum
numApples
What does the keyword final do?
It’s necessary to declare a variable.
Enables the use of println on a variable.
It prevents variables from being altered.
It indicates that the program has finished executing.
Which of the choices below is not a primitive type in Java?
int
String
char
double
Which of the following is true about primitive types in Java?
The value stored in a variable can be changed during program execution.
A variable is the name given to a memory location.
All variables must be declared before use.
All of these statements are correct for primitive variables in Java.
Which of the following could be stored in the variable
char initial;
"k"
'K'
"K"
All can be stored as a char in initial.
What explains the double type?
double can be assigned numbers like 1, 3, 3.5, -4
double can only assign numbers like 1, 4, -7, 10
double can only assign numbers like 1.5, 2.25, -16.987
double can only be assigned numbers like 1, 3, -4
Which Java Data Type would be the best suited to represent whether or not a student has completed their homework?
int
double
String
boolean
Which Java Data Type would be best suited to represent the amount of money in a bank account?
double
int
boolean
String
Which Java Data Type would be the best suited to represent the number of days left until Christmas Break?
int
boolean
double
String
What is the result of this expression?
17%6
(a)
Which of the below is NOT a Java arithmetic operator?
+
-
#
/
In Java, the = sign in a statement means
is equal to.
the left hand side is equal to the right hand side in the equation.
an assignment of the right hand side value to the left hand side variable.
that two equivalent relationships can be compared using a Boolean comparison.
What will this java expression evaluate to?
(int) 13.3
(a)
What is casting in Java?
Turning a value of one type into another type.
What Karel does when she breaks her leg.
A way to get user input in Java.
A way to print to the screen in Java.
