My Report

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. 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());
        }
    }

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

3. 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());
        }
    }

4. 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());
        }
    }

5. 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());
        }
    }

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

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

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

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

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


 

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

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.