Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1- The Scanner object can be used to convert String data to numeric data Select

ID: 670309 • Letter: 1

Question

1- The Scanner object can be used to convert String data to numeric data

Select one:

a. True

b. False

2- A for loop should always be used to process the tokens in a file

a. True

b. False

3- A for loop should always be used to process the tokens in a file

Select one:

a. True

b. False

4- Which method is used to read into a String variable

Select one:

a. nextInt()

b. nextDouble()

c. next()

d. any of the above

5- The Scanner object can be used with input from the keyboard and a text file

Select one:

a. True

b. False

6- Whitespace is the default delimiter used by the Scanner object when reading tokens

Select one:

a. True

b. False

7- Whitespace consists of

Select one:

a. only spaces

b. only tabs

c. only new lines

d. spaces, tabs, and new lines

8- What is the purpose of the following format specifier? "%10s"

Select one:

a. Left justify a string in 10 position

b. Right justify a string in 10 positions

c. Display the letter 's' 10 times

d. None of the above

9- What is the purpose of the following format specifier? "%8.3f"

Select one:

a. Left justify a floating point number in 8 positions with 3 decimal digits after the decimal point

b. Left justify a floating point number in 11 positions with 3 decimal digits after the decimal point

c. Right justify a floating point number in 8 positions with 3 decimal digits after the decimal point

d. Right justify a floating point number in 11 positions with 3 decimal digits after the decimal point

e. None of the above

10- What will display when this statement is executed? - System.out.printf("%6.2f", 123.000);

Select one:

a. 123

b. 123.00

c. 123.2

d. 6.2

e. 000123.00

Explanation / Answer

1. True
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods.

2.False
whille can be used

3. False
while can be used

4. d all of the above

nextInt() Scans the next token of the input as an int.
nextDouble() Scans the next token of the input as a double.
next() Finds and returns the next complete token from this scanner.

5. True

6. True

7. d. spaces, tabs, and new lines

A Scanner object divides its input into sequences of characters called tokens, using delimiters. A delimiter is a character that is used to separate other characters. The default delimiters are the standard whitespace characters: space, tab, and newline

8.
b. Right justify a string in 10 position
it first print 10 space and then print string

9.
c. Right justify a floating point number in 8 positions with 3 decimal digits after the decimal point

10.
b. 123.00

.