Files and I/O


  1. Which of these classes can return more than one character to be returned to input stream?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    PushbackReader class allows one or more characters to be returned to the input stream. This allows looking ahead in input stream and performing action accordingly.


  1. Which of these method of FileReader class is used to read characters from a file?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    read()



  1. Which of these class can be used to implement the input stream that uses a character array as the source?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    CharArrayReader is an implementation of an input stream that uses character array as a source. Here array is the input source.


  1. Which of these class is used to read characters in a file?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    FileReader



  1. What is the output of this program?
    import java.io.*;
    public class Chararrayinput_Example
    {
    public static void main(String[] args)
    {
    String object = "Interview Mania";
    int length = object.length();
    char p[] = new char[length];
    object.getChars(0,length,p,0);
    CharArrayReader input1 = new CharArrayReader(p);
    CharArrayReader input2 = new CharArrayReader(p, 0, 3);
    int K;
    try
    {
    while ((K = input1.read()) != -1)
    {
    System.out.print((char)K);
    }
    }
    catch (IOException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Interview Mania