Font size
WorksheetsJava Variables, Input and Output
Total questions: 15
Worksheet time: 10mins
What values can a boolean variable store?
true
false
hum hum
4
The value 'e' would be best stored in a _____ type of variable.
char
int
double
boolean
An int type variable can only store
whole numbers
real numbers
zeroes
Numbers less than 1000
We store real numbers in this type of variable:
double
single
int
char
To store text like a name or address we use this type of variable:
String
text
letters
string
To output or display data on the screen we use:
System.out.println()
Print()
System.display()
JOptionPane.toScreen()
The shortcut for System.out.println is:
sout <TAB>
salt <TAB>
sop <TAB>
<Ctrl> <P>
To output a String and an int next to each other we use this character to join them:
+
,
SPACE
\t in a print statement causes this to be printed:
a tab
a small t
a backslash and a t
To input data use this command:
JOptionPane.showInputDialog("")
JOptionPane.showInput("")
JOptionPane.inputData("")
The JOptionPane.showInputDialog("") command returns this type of data:
a String
a real number
an integer
a character
To input a String we use:
name = (a) ("Input your name"));
To input an integer, we use:
int num = (a) (JOptionPane.showInputDialog("") ) ;
To input a char we use:
ch = JOptionPane.showInputDialog("Input a character"). (a) ;
To input a real number we use:
realNum = (a) (JOptionPane.showInputDialog("Input a real number"));
