A good answer might be:

  • Have you already used System.out?
  • Yes, System.out.println("Some string" + 123) sends characters to the ouput stream.
  • Did it have to convert a primitive numeric type to character data?
  • Yes, "Some string" + 123 converts the integer 123 from a primitive numeric type into characters that are appended to "Some string".

Example IO Program

The following program reads characters from the keyboard into the String called inData. Then the characters stored in that String are sent to the monitor. The details of this program are explained in the next several pages.

import java.io.*;
class Echo
{
  public static void main (String[] args) throws IOException
  {
    InputStreamReader inStream = new InputStreamReader( System.in ) ;
    BufferedReader stdin = new BufferedReader( inStream );
 
    String inData;

    System.out.println("Enter the data:");
    inData = stdin.readLine();

    System.out.println("You entered:" + inData );
  }
}
The line  import java.io.*;  says that the package java.io will be used. The  *  means that any class inside the package might be used. Here is how this program runs:
C:\users\default>java Echo

Enter the data:
This is what the user enters
You entered:This is what the user enters

C:\users\default>

QUESTION 5:

Could the user have included digits 0, 1, ... 9 in the input characters?

Click Here after you have answered the question