My Report (&Account)

Java I/O Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of these is method for testing whether the specified element is a file or a directory?

2. What will be the output of the following Java program? (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.getParent());
            System.out.print(" " + obj.isFile());
        }
    }

3. Which of these is specified by a File object?

4. Which of these class is not related to input and output stream in terms of functioning?

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

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

7. What will be the output of the following Java program considering that the filename sanfoundry.java exists and is readable but not writable?

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

8. Which of these packages contain classes and interfaces used for input & output operations of a program?

9. What will be the output of the following Java program? (Note: file is made in c drive.)

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

10. What will be the output of the following Java code?

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

 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.