Java MCQ Questions - Java.io

This section focuses on the "Java.io" of Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. Java I/O is used to process the?

A. input 
B. output
C. Both A and B
D. None of the above

View Answer


2. Can we perform file handling in Java by Java I/O API?

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


3. In java, how many streams are created for us automatically?

A. 2
B. 3
C. 4
D. 5

View Answer


4. Which method is used to write a byte to the current output stream?

A. public void write(int)throws IOException
B. public void write(byte[])throws IOException
C. public void flush()throws IOException
D. public void close()throws IOException

View Answer


5. Which method is used to write an array of byte to the current output stream?

A. public void write(int)throws IOException
B. public void write(byte[])throws IOException
C. public void flush()throws IOException
D. public void close()throws IOException

View Answer


6. Which of these class is not a member class of java.io package?

A. File
B. StringReader
C. Writer
D. String

View Answer


7. ObjectFilter is a member of java.io package.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


8. ___________ returns true if called on a file and returns false when called on a directory.

A. IsFile()
B. Isfile()
C. isFile()
D. isfile()

View Answer


9. What will be output for the following code?

    import java.io.*;
    class files 
    {
        public static void main(String args[]) 
        {
            File obj = new File(""/java/system"");
            System.out.print(obj.getName());
        }
    }

A. java
B. system
C. java/system
D. /java/system

View Answer


10. What will be output for the following code? Note: file is made in c drive

import java.io.*;
    class files 
    {
        public static void main(String args[]) 
        {
            File obj = new File(""/java/system"");
            System.out.print(obj.canWrite());
            System.out.print("" "" + obj.canRead());
        }
    }

A. true false
B. false true
C. true true
D. false false

View Answer



Discussion


* You must be logged in to add comment.