wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

3.2 Data Type, Operator & Expression in Java (part 1)

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

Determine whether the following identifier is valid or invalid.

int -d;

a)

True

b)

False

2.

Determine whether the following identifier is valid or invalid.

int _$;

a)

True

b)

False

3.

Determine whether the following identifier is valid or invalid

int this_is_a_detailed_name_for_identifier;

a)

True

b)

False

4.

Determine whether the following identifier is valid or invalid.

int :b;

a)

True

b)

False

5.

Determine whether the following identifier is valid or invalid

int e#;

a)

True

b)

False

6.

Determine whether the following identifier is valid or invalid.

int 7g;

a)

True

b)

False

7.

Determine whether the following identifier is valid or invalid

int _$c;

a)

True

b)

False

8.

Determine whether the following identifier is valid or invalid.

int 2_w;

a)

True

b)

False

9.

Determine whether the following identifier is valid or invalid.

int .f;

a)

True

b)

False

10.

Determine whether the following identifier is valid or invalid.

int _a;

a)

True

b)

False

11.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
12.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

13.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

14.

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

a)

boolean

b)

String

c)

double

d)

int

15.

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

a)

double

b)

String

c)

int

d)

char

16.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

17.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

18.

A computer walks into a bar...

a)

Ouch.

b)

Sorry, we don't server here.

c)

ERROR 404: Does not compute

d)

Great, computers are self-aware now.

19.

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

a)

string name = "Elroy";

b)

name String = "Elroy";

c)

String name = Elroy;

d)

String name = "Elroy";

e)

Me llamo Elroy

20.

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

a)

String

b)

char

c)

boolean

d)

None of these

e)

blonde

21.

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";

e)

I do hereby declare thee Sir Tax Rate

22.

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";

e)

Trick question - no one passes this class

23.

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")

e)

What is love? Baby dont hurt me. Dont hurt me. No more.

24.

A variable that holds words

a)

String

b)

boolean

c)

int

d)

float

e)

A dictionary

25.

A variable that holds true or false

a)

String

b)

boolean

c)

int

d)

float

e)

Alex Trebek

26.

1.Java (a)   keyword is used to declare a variable as a True and False values only.

27.

2.Java (a)   keyword is used to declare a variable that can hold an 8-bit data values.

28.

3. Java (a)   keyword is used to declare a variable that can hold unsigned 16-bit Unicode characters

29.

4.Java (a)   keyword is used to declare a variable that can hold a 64-bit floating-point numbers.

30.

5. Java (a)   keyword is used to declare a variable that can hold a 32-bit signed integer.

31.

6.Java (a)   keyword is used to declare a variable that can hold a 64-bit integer.

32.

7.Java (a)   keyword is used to indicate that a reference does not refer to anything. It removes the garbage value.

33.

8.Java (a)   keyword is used to return from a method when its execution is complete.

34.

9.Java (a)   keyword is an access modifier. It is used to indicate that an item is accessible anywhere. It has the widest scope among all other modifiers.

35.

10.Java (a)   keyword makes classes and interfaces available and accessible to the current source code.