Given the proper import statements and:
23. try { 24. File file = new File("myFile.txt"); 25. PrintWriter pw = new PrintWriter(file); 26. pw.println("line 1"); 27. pw.close(); 28. PrintWriter pw2 = new PrintWriter("myFile.txt"); 29. pw2.println("line 2"); 30. pw2.close(); 31. } catch (IOException e) { }
What is the result? (Choose all that apply.)
B and F are correct.
Both PrintWriter constructors are valid.
When the second constructor is called, it truncates the existing file to zero size, then "line 2" is added to the file by the second println()
.