wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JAVA BASIC 2

Total questions: 35

Worksheet time: 29mins

Name
Class
Date
1.
What format do I use to print words in JAVA?
a)
System.out.println("Words");
b)
System.out.println(True);
c)
System.out.println(words);
d)
System.out.println('Character');
2.
How do I print out numbers on JAVA?
a)
System.out.println(#);
b)
System.out.println("#");
c)
System.out.println('#');
d)
System.out.println(false);
3.
What are booleans in JAVA?
a)
True or False statements
b)
A way to lean the coding to one side.
c)
A way to write numbers.
d)
They are the proper way of writing code.
4.
When I set a variable, all commands should end with what?
a)
?
b)
:
c)
;
d)
" "
5.
How do I insert a multi-line comment?
a)
/* Comment */
b)
? Comment ?
c)
Comment **
d)
-Java Comment-
6.
Does white-space effect the coding in JAVA?
a)
Yes
b)
No 
c)
Sometimes
7.

Which is the correct Java code to display the phrase "Java!"?

a)

System.Out.Print("Java!");

b)

System.Out.print("Java!");

c)

System.out.Print("Java!");

d)

System.out.print("Java!");

8.

Which primitive type is for floating point decimals?

a)

boolean

b)

char

c)

double

d)

long

9.

Which accepts the smallest range of values?

a)

byte

b)

int

c)

long

d)

short

10.

Which puts the cursor on the next line after printing a String?

a)

next()

b)

nextLine()

c)

print()

d)

println()

11.

Which identifier is not legal in java?

a)

class1

b)

2legit2quit

c)

HappyDays

d)

Whats_up_with_that

12.
What does a comment look like in Java?
a)
//comment
b)
\\comment
c)
==comment
d)
\comment
13.

Begins and ends the body of class and method

a)

[ ]

b)

;

c)

{ }

d)

:

14.

Which of the following represents a single line command in Java?

a)

<!-- Comment -->

b)

// Comment

c)

/* Comment */

d)

# Comment

15.

What does the Java code print?

a)

0

b)

8

c)

true

d)

false

e)

pancakes

16.

Java will ignore whitespace in code.

a)

True

b)

False

17.

The variable "trash" will store what value?

a)

2

b)

10

c)

1

d)

3

18.

The variable "grade" will store what value?

a)

15

b)

5

c)

orange

d)

6

e)

11

19.

The expression will equate to what value?

a)

5

b)

false

c)

true

d)

6

20.

What does the Java code print?

a)

true

b)

2 = 2

c)

2

d)

false

21.

Boolean 'and' is represented in Java by what operator?

a)

$$

b)

&&

c)

and

d)

||

22.

Boolean 'or' is represented in Java by what operator?

a)

!!

b)

OR

c)

||

d)

[[

23.

What will the code print?

a)

Jimmy

b)

Timmy

c)

Potatoes

d)

A blank line

24.

What will the code print?

a)

true

b)

false

c)

13

d)

2

25.

Which of the following shows the possible outcomes for the && operator

a)
b)
26.

What will the code print to the console?

a)

true

b)

false

27.

Precedence: What will the output be?

a)

true

b)

false

c)

coding is hard :/

28.

What will the output be?

a)

Control Flow Rocks

b)

Else Rules

29.

What will the output be?

a)

Control Flow Rocks

b)

Else Rules

30.

What will the output be?

a)

1

b)

2

c)

3

d)

4

31.

What will the output be?

a)

Big Feet, go away!

b)

In Stock

c)

Your feet are too small for this store!

32.

What will the output be?

a)

Big Feet, go away!

b)

In Stock

c)

Your feet are too small for this store!

33.

What value is printed to the console?

a)

true

b)

W

c)

false

d)

L

34.

What value is printed to the console?

a)

false

b)

Y

c)

true

d)

N

35.

What value is printed to the console?

a)

This restaurant is not my favourite.

b)

This restaurant is good.

c)

This restaurant is fantastic!

d)

I've never dined at this restaurant.

e)

3