wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Basics (Data Types and Variables)

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

2.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

3.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

4.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

5.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

6.

What data type would you use for storing the average test score in a class?

a)

double

b)

String

c)

int

d)

char

7.

What data type would you use for storing letter grades (without - or +) for students in a class?

a)

String

b)

char

c)

int

d)

boolean

8.

What data type would you use to store names of students?

a)

String

b)

char

c)

boolean

d)

None of these

9.

How would you declare a variable storing a person's name?

a)

string name = "Jeff";

b)

name String = "Jeff";

c)

String name = Jeff;

d)

String name = "Jeff";

10.

How would you declare a variable storing the tax rate?

a)

int taxRate = 5.1;

b)

taxRate = "5.1";

c)

double taxRate = 5.1;

d)

double taxRate = "5.1";

11.

How would you declare a variable that tells you that someone passed a class?

a)

boolean passed = 'true';

b)

boolean passed = true;

c)

passed = true;

d)

String passed = "true";

12.

Which expression evaluates to true?

a)

false == false

b)

true != true

c)

4 < 4

d)

true == true != true

13.

Which expression evaluates to false?

a)

15 % 3 < 2

b)

3 * 3 % 2 <= 0

c)

false == false

d)

false == false == false == false

14.

Which declaration with throw an error?

a)

String name = "1 1233 141";

b)

double num = 1;

c)

int bigNumber = 1234567890;

d)

char random = '7';

15.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

16.

What prints out "I love Java" successfully?

a)

System.out.println(I love Java);

b)

Systemoutprintln("I love Java);

c)

System.out.println("I love" + " Java");

d)

System.out.println("I love Java")