Chapter 2 - revisited Flashcards

1
Q

when using the scanner class - how do you scan in more than one number in a row? how are the prompt(s) used with the scan.in ?

A

only one string statement is needed before implementing several scanner objects. you do not need to repeat the string statement.
ex:
System.out.println(“ please enter the two numbers”)
num1 = scan.nextInt()
num2 = scan.nextInt()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the statement used to invoke the scanning method and giving it a variable name?

A

scanner scan = new scanner (System.in);
^class ^variable name for the scanning method.

when using the scan method we concadinate the variable name we chose with the type of data coming in.
example
number1= scan.nextInt();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a numeric literal?

A

numeric literal is a number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are variables?

A

variables: words that hold values and can change in value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how are character variables instantiated? what is the format?

A

char letterChosen = ‘A’;

^type ^variable name ^ the single ‘ is used for characters whereas a double “ is used for strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

is it possible to assign a boolean to variable words and if so how?

A

boolean yes = true;
boolean no = false;
now the words yes and no represent true and false and can be written into code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly