Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Primitive Practice

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Which of the following is not a primitive data type in Java?

a)
int
b)
String
c)
boolean
d)
char
2.

Which data type is used to store whole numbers in Java?

a)
float
b)
double
c)
int
d)
char
3.

What is the range of the int data type in Java?

a)
-2,147,483,648 to 2,147,483,647
b)
-32,768 to 32,767
c)
0 to 4,294,967,295
d)

-2,648 to 2,647

4.

Which data type is used to store characters in Java?

a)
int
b)
float
c)
char
d)
boolean
5.

Which of the following is a proper way to declare a variable in Java?

a)

myInteger = 100;

b)

char = 'a';

c)

int myNumber = 10;

d)

int myNumber;

6.

Which of the following is a proper way to declare and initialize a variable in Java?

a)

myInteger = 100;

b)

char = 'a';

c)

int myNumber = 10;

d)

int myNumber;

7.

Which of the following variable names follows best practices for naming a variable?

a)

5apples

b)

someVariable

c)

applesnum

d)

numApples

8.

What does the keyword final do?

a)

It’s necessary to declare a variable.

b)

Enables the use of println on a variable.

c)

It prevents variables from being altered.

d)

It indicates that the program has finished executing.

9.

Which of the choices below is not a primitive type in Java?

a)

int

b)

String

c)

char

d)

double

10.

Which of the following is true about primitive types in Java?

a)

The value stored in a variable can be changed during program execution.

b)

A variable is the name given to a memory location.

c)

All variables must be declared before use.

d)

All of these statements are correct for primitive variables in Java.

11.

Which of the following could be stored in the variable

char initial;

a)

"k"

b)

'K'

c)

"K"

d)

All can be stored as a char in initial.

12.

What explains the double type?

a)

double can be assigned numbers like 1, 3, 3.5, -4

b)

double can only assign numbers like 1, 4, -7, 10

c)

double can only assign numbers like 1.5, 2.25, -16.987

d)

double can only be assigned numbers like 1, 3, -4

13.

Which Java Data Type would be the best suited to represent whether or not a student has completed their homework?

a)

int

b)

double

c)

String

d)

boolean

14.

Which Java Data Type would be best suited to represent the amount of money in a bank account?

a)

double

b)

int

c)

boolean

d)

String

15.

Which Java Data Type would be the best suited to represent the number of days left until Christmas Break?

a)

int

b)

boolean

c)

double

d)

String

16.

What is the result of this expression?

17%6

(a)  

17.

Which of the below is NOT a Java arithmetic operator?

a)

+

b)

-

c)

#

d)

/

18.

In Java, the = sign in a statement means

a)

is equal to.

b)

the left hand side is equal to the right hand side in the equation.

c)

an assignment of the right hand side value to the left hand side variable.

d)

that two equivalent relationships can be compared using a Boolean comparison.

19.

What will this java expression evaluate to?

(int) 13.3

(a)  

20.

What is casting in Java?

a)

Turning a value of one type into another type.

b)

What Karel does when she breaks her leg.

c)

A way to get user input in Java.

d)

A way to print to the screen in Java.