java Flashcards

1
Q

The program uses import java.util.Scanner;

A

for access to the Scanner class.

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

Scanner inSS = null;

A

declares a Scanner object.

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

The statement inSS = new Scanner(userInfo);

A

assigns the associated input stream with a copy of userInfo. Then, the program can extract data from the scanner inSS using the family of next() methods (e.g., next(), nextInt(), nextDouble(), etc.).

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

A common use of string streams is

A

to process user input line-by-line.

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

inSS = new Scanner(lineString);

A

uses the Scanner’s constructor to initialize the stream’s buffer to the String lineString.

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

output string stream

A

can be created that is associated with a string rather than with the screen (standard output)

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

An output string stream is created using both

A

1) the StringWriter
import java.io.StringWriter;
2) PrintWriter classes
import java.io.PrintWriter;

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

The StringWriter class provides

A

a character stream that allows a programmer to output characters

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

The PrintWriter class is

A

a wrapper class that augments(الزيادات) character streams, such as StringWriter, with print() and println() methods that allow a programmer to output various data types

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

To create a PrintWriter object,

A

the program must first create a StringWriter, passing the StringWriter object to the constructor for the PrintWriter.

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

PrintWriter object provides

A

the print() and println() methods for writing to the stream,

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

StringWriter object provides

A

the toString() method for getting the resulting String

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

userInput = scnr.nextLine();
inSS = new Scanner(userInput);
userMonth = inSS.next();
userDate =inSS.nextInt();
userYear = inSS.nextInt();

A

read

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

output formatting

A

programmer can adjust the way that a program’s output appears

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

the standard output stream System.out provides the methods

A

1- printf() and
2- format()

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

format string

A

specifies the format of the text to print along with any number of placeholders for printing numeric values.

17
Q

The placeholders are known as

A

format specifiers

18
Q

format specifier

A

specifies the type of value to print in its place

20
Q

sub-specifier

A

provides formatting options for a format specifier and are included between the % and format specifier character.