Is your car's computer doing input and output?

A good answer might be:

Yes---data is being input from sensors and output to controllers.

IO Streams

If the car's computer program were written in Java, it would use a specialized IO package that manages sensors and controllers. It would not use the IO package that deals with keyboards and terminals.

In Java, a source of input data is called an input stream and the output data is called an output stream. Think of these streams like this:

In this picture, each "O" is supposed to be a datum (chunk of data) waiting in line to be input, or leaving as output. Inputing data is usually called reading data; and outputing data is usually called writing data (or printing data if the output stream is connected to a monitor or a printer.)

You might think of the input stream as a string of pearls which the program inputs one at a time, in order. The output stream is a string of new pearls (not usually the same ones as came in.) Often a program will have to input several data in a row before it has enough to process. For example, the input data might be a list of numbers, the output data might be their sum.

There are three IO streams usually connected to your program:

  • System.in --- the input stream.
  • System.out --- the output stream for normal results.
  • System.err --- the output stream for error messages.
Normally System.in is connected to the keyboard and the data are characters. System.out and System.err both are connected to the monitor, and both are character data. These streams are difficult to manage by themselves. We will use the package java.io to help.

QUESTION 3:

What does the keyboard send to your program when you type the following:

1234

Click Here after you have answered the question