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

a) java true
b) java false
c) \java false
d) \java true

1 thought on “What will be the output of the following Java program? (Note: file is made in c drive.)”

  1. c
    Explanation: getparent() giver the parent directory of the file and isfile() checks weather the present file is a directory or a file in the disk.
    Output:
    $ javac files.java
    $ java files
    \java false

Leave a Comment