wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Variables, Input and Output

Total questions: 15

Worksheet time: 10mins

Name
Class
Date
1.

What values can a boolean variable store?

a)

true

b)

false

c)

hum hum

d)

4

2.

The value 'e' would be best stored in a _____ type of variable.

a)

char

b)

int

c)

double

d)

boolean

3.

An int type variable can only store

a)

whole numbers

b)

real numbers

c)

zeroes

d)

Numbers less than 1000

4.

We store real numbers in this type of variable:

a)

double

b)

single

c)

int

d)

char

5.

To store text like a name or address we use this type of variable:

a)

String

b)

text

c)

letters

d)

string

6.

To output or display data on the screen we use:

a)

System.out.println()

b)

Print()

c)

System.display()

d)

JOptionPane.toScreen()

7.

The shortcut for System.out.println is:

a)

sout <TAB>

b)

salt <TAB>

c)

sop <TAB>

d)

<Ctrl> <P>

8.

To output a String and an int next to each other we use this character to join them:

a)

+

b)

,

c)

SPACE

9.

\t in a print statement causes this to be printed:

a)

a tab

b)

a small t

c)

a backslash and a t

10.

To input data use this command:

a)

JOptionPane.showInputDialog("")

b)

JOptionPane.showInput("")

c)

JOptionPane.inputData("")

11.

The JOptionPane.showInputDialog("") command returns this type of data:

a)

a String

b)

a real number

c)

an integer

d)

a character

12.

To input a String we use:

name = (a)   ("Input your name"));

13.

To input an integer, we use:

int num = (a)   (JOptionPane.showInputDialog("") ) ;

14.

To input a char we use:

ch = JOptionPane.showInputDialog("Input a character"). (a)   ;

15.

To input a real number we use:

realNum = (a)   (JOptionPane.showInputDialog("Input a real number"));