x

Java Files Questions

PREV     NEXT

Java Files Questions:


  1. Which abstract class is the super class of all classes used for reading bytes. Select the one correct answer.
    1. Reader
    2. FileReader
    3. ByteReader
    4. InputStream
    5. FileInputStream
  2. Which abstract class is the super class of all classes used for writing characters. Select the one correct answer.
    1. Writer
    2. FileWriter
    3. CharWriter
    4. OutputStream
    5. FileOutputStream
  3. Which of these are legal ways of accessing a File named “file.tst” for reading. Select the two correct answers.
    1. FileReader fr = new FileReader(“file.tst”);
    2. FileInputStream fr = new FileInputStream(“file.tst”);
      InputStreamReader isr = new InputStreamReader(fr, “UTF8”);
    3. FileReader fr = new FileReader(“file.tst”, “UTF8”);
    4. InputStreamReader isr = new InputStreamReader(“file.tst”);
  4. Name the class that allows reading of binary representations of Java primitives from an input byte stream.
  5. Which of these classes are abstract. Select the three correct answers.
    1. FilterWriter
    2. Reader
    3. InputStream
    4. CharArrayReader
    5. DataInputStream
  6. Name the exception thrown by the read method defined in InputStream class

Answers to questions on Files and I/O


  1. d
  2. a
  3. a, b. FileReader class uses the default character encoding, hence c is incorrect. InputStreamReader character class does not have a constructor that takes file name as an argument. Hence d is incorrect.
  4. DataInpiutStream
  5. a,b,c
  6. IOException

PREV     NEXT



Like it? Please Spread the word!

Post Your Thoughts