Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Quiz

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

What is the keyword to stop a loop?

a)

stop

b)

break

c)

cancel

d)

forcestop

2.

What is the correct main method?

a)

public main(String arg)

b)

public static void main()

c)

public static void main(String[] args)

d)

public static boolean main(String args[])

3.

How do you correctly delay the thread for 3 seconds correctly?

a)

Thread.sleep(3);

b)

Thread.delay(300);

c)

Thread.sleep(3000);

d)

Thread.sleepForSeconds(3);

4.

Which if statement is the most correct?

a)

if 5 > i

b)

if (5) > (i++)

c)

if (5 > i)

d)

if (5 <= i)

5.

You can move the expression:

package com.login;

anywhere in your class?

a)

True

b)

False

6.

Can this ever be possible?:

public Main() {

a)

True

b)

False

7.

What is the correct way to return the variable 'var' in a method?

a)

returnValue(var);

b)

return(var);

c)

return var;

d)

(return (var));

8.

How would you print a message in java?

a)

System.print("Hello World!");

b)

println("Hello World!");

c)

System.out.printline("Hello World!");

d)

System.out.println("Hello World!");