FAQ
Java Tutorial
Questions by Topic
Mock exam 1
Mock exam 2
Whizlabs
Other Certification sites
Certification Tips
Exam Objectives
Java jobs
Java News
About Java Prepare
Books
Certification Books
SCEA Books
Online Books
Tutorial Topics
Language Fundamentals
Operator and Assignments
Declaration and Access Control
Classes in Java
Threads
Files
Advertisements
 
javaprepare.com
your tool for Java Certification
home | tutorial | questions | test 1

Questions on Files and Input/Output

  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

home | tutorial | questions | test 1