Menu
Question Index
...

What will be output of the following program? Assume that directory structure is already created.

import java.io.*;
public class InputStreamDemo {
    public static void main(String[] args) throws IOException {
        File f = new File("D:\\Programs\\College.java");
        InputStream is = new FileInputStream(f);
        if (f.exists()) {
            System.out.println("File exists.");
        } else
            System.out.println("File not found.");
        is.close();
    }
}


File exists.
File not found.
Compilation Error
Runtime Error because java.io.FileNotFoundException

Doubts

Problems

Topic: Java FileInputStream

Read this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App