What is the output for the following lines of code? import java.io.*; public class FileHandling { public static void main (String[] arg) throws Exception { File f = new File ("ll.txt"); FileOutputStream s = new FileOutputStream(f); PrintStream p = new PrintStream (s); p.println("hi"); } }

  1. A. It would fail to compile

  2. B. It would generate a run-time error on execution.

  3. C. It would execute, but ask the user to specify the directory in which to create ll.txt.

  4. D. It would execute without an error and print "hi" to a file called ll.txt


Correct Option: D

Find more quizzes: