PREV NEXT
Java Files Questions:
- Which abstract class is the super class of all classes used for reading bytes. Select the one correct answer.
- Reader
- FileReader
- ByteReader
- InputStream
- FileInputStream
- Which abstract class is the super class of all classes used for writing characters. Select the one correct answer.
- Writer
- FileWriter
- CharWriter
- OutputStream
- FileOutputStream
- Which of these are legal ways of accessing a File named “file.tst” for reading. Select the two correct answers.
- FileReader fr = new FileReader(“file.tst”);
- FileInputStream fr = new FileInputStream(“file.tst”);
InputStreamReader isr = new InputStreamReader(fr, “UTF8”); - FileReader fr = new FileReader(“file.tst”, “UTF8”);
- InputStreamReader isr = new InputStreamReader(“file.tst”);
- Name the class that allows reading of binary representations of Java primitives from an input byte stream.
- Which of these classes are abstract. Select the three correct answers.
- FilterWriter
- Reader
- InputStream
- CharArrayReader
- DataInputStream
- Name the exception thrown by the read method defined in InputStream class
Answers to questions on Files and I/O
- d
- a
- 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.
- DataInpiutStream
- a,b,c
- IOException
Post Your Thoughts