Simple Input/Output

Input is the data entered by the user. Output is any information that a program conveys to the user. Java provides a class System that has three important fields in, out and err which help the user to give the input, take the output and display an error respectively. InputStream and PrintStream are a part of Java IO streams and contained in java.io.package. A string can be printed using print() and println() methods of PrintStream class. The println() terminates the current line by writing a line separator at the end of the string, while the print() method only displays the string.

System.in.read() reads one character from the keyboard and returns the equivalent ASCII value. Two main Java stream classes are InputStream and OutputStream. InputStream is an abstract class, which is the super class of all classes representing an input stream. OutputStream is an abstract class, which is the super class of all classes representing an output stream. The class System provides access to three streams: System.in, System.out and System.err. The two types of Java streams are CharacterOriented Stream and ByteOriented Stream. The CharacterOriented reads input in character form. The ByteOriented Stream reads input in binary form. Java IO classes used to receive input from the user are Java.io.InputStream, Java.io.InputStreamReader and Java.io.BufferedReader. Java InputStreamReader class translates data bytes received from an InputStream into a stream of characters. Java BufferedReader class buffers the input data received from InputStreamReader. Java provides a wrapper class for each primitive data type. All wrapper classes contain static methods for changing the string data into primitive data type.

To Access the full content, Please Purchase

  • Q1

    What term is used in computer language when the user receives the result of the program on the screen?

    Marks:1
    Answer:

    The term used is output. Output is any information that the program displays to the user.

    View Answer
  • Q2

    What are the ways by which an input can be given?

    Marks:1
    Answer:

    Input can be given in the following ways:

    Character input, mouse click, audio input, graphic input.

    View Answer
  • Q3

    Name the class in which readLine() function exists?

    Marks:1
    Answer:

    BufferedReader class

    View Answer
  • Q4

    What term is used in computer language when the user sends the data or information needed in the program?

    Marks:1
    Answer:

    The term used is input. Input is any information that is needed by the program to complete its execution.

    View Answer
  • Q5

    What are library classes in java?

    Marks:1
    Answer:

    Java includes predefined classes in the form of packages which are called Java library classes.

    View Answer