Chapter 13 Flashcards

1
Q

Question: In Java programming, when do you typically obtain input from the keyboard, and when do you store data onto a disk file?

A

Answer: In smaller programs, keyboard input is often used to gather data, while for larger programs, data is frequently stored onto disk files in the computer’s hard drive.

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

What is the flow of input from the keyboard to the computer screen?

A

From the keyboard to the computers innards to the computer screen

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

Q: How does data flow when typing on a keyboard to print onto the screen?

A

A: When you type on the keyboard, the characters are sent to the computer’s memory, where they’re processed and then displayed on the screen.

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

Q: What about when writing onto a disk file?

A

A: When writing onto a disk file, the data from the keyboard is also initially stored in the computer’s memory. However, instead of being directly displayed on the screen, it’s transferred to a buffer and then written onto the disk by the operating system.

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

Q: What happens after the data is written onto the disk?

A

A: The data is stored in the disk’s physical sectors or blocks, typically in a file allocated for this purpose.

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

Q: How is the data retrieved and displayed when accessing a disk file?

A

A: When you want to view the contents of the file, the operating system reads the data from the disk and transfers it to the memory. Then, it may be displayed on the screen depending on how the program is designed.

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

Q: What’s the main difference between printing onto the screen and writing onto a disk file?

A

A: The main difference lies in the storage aspect. Printing to the screen involves immediate display of input characters, while writing to a disk file saves the data for future retrieval and can be accessed even after the computer is turned off.

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

Q: How does Scanner differ from PrintStream in Java?

A

A: Scanner is used for obtaining input from various sources, such as the console or files, while PrintStream is used for outputting data from the program to the console or other output streams.

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

Q: What happens when a program uses a Scanner for input?

A

A: The program waits for the user to provide data, which is then read by the Scanner and brought into the program.

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

Q: When does the console prompt for input appear?

A

A: The console prompt appears when a program using a Scanner is waiting for the user to provide input.

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

Q: What does a program using PrintStream do?

A

A: It sends data from the program to the console for display, typically predetermined by the code and not requiring direct user interaction at that moment.

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

Q: How does Scanner differ from PrintStream in Java?

A

A: Scanner is used for obtaining input from various sources, such as the console or files, while PrintStream is used for outputting data from the program to the console or other output streams.

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

Q: What happens when a program uses a Scanner for input?

A

A: The program waits for the user to provide data, which is then read by the Scanner and brought into the program.

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

Q: When does the console prompt for input appear?

A

A: The console prompt appears when a program using a Scanner is waiting for the user to provide input.

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

Q: What does a program using PrintStream do?

A

A: It sends data from the program to the console for display, typically predetermined by the code and not requiring direct user interaction at that moment.

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