Chapter 2 - revisited Flashcards Preview

Java 1 > Chapter 2 - revisited > Flashcards

Flashcards in Chapter 2 - revisited Deck (6)
Loading flashcards...
1

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 ?

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()

2

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

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();

3

what is a numeric literal?

numeric literal is a number

4

what are variables?

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

5

how are character variables instantiated? what is the format?

char letterChosen = 'A';
^type ^variable name ^ the single ' is used for characters whereas a double " is used for strings.

6

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

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