5. public class Test{public static String output="";public static void foo(int i){try {if(i==1){ throw new Exception(); }output +="1";}catch(Exception e){output+="2";return;}finally{output+="3";}output+="4";}public static void main(String args[]){foo(0);foo(1);24)}}what is the value of output at line 24?Answer:134237. class ExceptionTest{public static void main(String args[]){try{methodA();}catch(IOException e){System.out.println("caught IOException");}catch(Exception e){System.out.println("caught Exception");}}}If methodA() throws a IOException, what is the result? Answer:caught IOException40. public class ExceptionTest{class TestException extends Exception{}public void runT est() throws TestException{}public void test() /* point x */ {runTest();}}At point x, which code can be add on to make the code compile?A.throws ExceptionB.catch (Exception e)Answer:A38. which four types of objects can be thrown use "throw"?A.ErrorB.EventC.ObjectD.ExceptionE.ThrowableF.RuntimeExceptionAnswer:A、D、E、F67. which gets the name of the parent directory of file "file.txt"?A. String name=File.getParentName("file.txt");B. String name=(new File("file.txt")).getParent();C. String name=(new File("file.txt")).getParentName();D. String name=(new File("file.txt")).getParentFile();E. Diretory dir=(new File("file.txt")).getParentDir();String name=dir.getName();Answer:B68. The file "file.txt" exists on the file system and contains ASCII text.try{File f=new File("file.txt");OutputStream out=new FileOutputStream(f);}catch (IOException e){}A. the code does not compileB. the code runs and no change is made to the fileC. the code runs and sets the length of the file to 0D. An exception is thrown because the file is not closedE. the code runs and deletes the file from the file systemAnswer:C80. //point Xpublic class Foo{public static void main(String[] args){PrintWriter out=new PrintWriter(new java.io.OutputStreamWriter(System.out),true);out.println("Hello");}}which statement at point X on line 1 allows this code to compile and run?A.import java.io.PrintWriterB.include java.io.PrintWriterC.import java.io.OutputStreamWriterD.include java.io.OutputStreamWriterE.No statement is neededAnswer:A84. what writes the text "<end>" to the end of the file "file.txt"?A.OutputStream out=new FileOutputStream("file.txt");out.writeBytes("<end>\n");B.OutputStream os=new FileOutputStream("file.txt",true);DataOutputStream out=new DataOutputStream(os);out.writeBytes("<end>\n");C.OutputStream os=new FileOutputStream("file.txt");DataOutputStream out=new DataOutputStream(os);out.writeBytes("<end>\n");D.OutputStream os=new OutputStream("file.txt",true);DataOutputStream out=new DataOutputStream(os);out.writeBytes("<end>\n");Answer:B85. which constructs a DataOutputStream ?A.new DataOutputStream("out.txt");B.new DataOutputStream(new File("out.txt"));C.new DataOutputStream(new Writer("out.txt"));D.new DataOutputStream(new OutputStream("out.txt"));E.new DataOutputStream(new FileWriter("out.txt"));F.new DataOutputStream(new FileOutputSream("out.txt")); Answer:F86. which statement is true for the class java.util.HashSet?A.The elements in the collection are orderedB.The collection is guaranteeded to be immutableC.The elements in the collection are guaranteeded to be uniqueD.The elements in the collection are access using a unique keyE.The elements in the collection are guaranteed to be synchronized Answer:C94. which two creat an InputStream and open the file"file.txt"for reading?A.InputStream in=new FileInputStream("file.txt");B.FileInputStream in=new FileInputStream(new File("file.txt"));C.InputStream in=new FileReader("file.txt");Answer:A、B95. which constructs a BuferedInputStream?A.new BufferedInputStream(new FileInputStream("in.txt"));B.new BufferedInputStream(new FileReader("in.txt"));Answer:A96. which can be used to encode char s for output?A.java.io.OutputStreamWriterB.java.io.FileOutputStreamC.java.io.DataOutputStreamAnswer:A97. which determines if "prefs" is a directory and exist on the file system?A.boolean exists=(new File("prefs")).isDirectory();B.boolean exists=(new File("prefs")).isDir();Answer:A100. which is true?A. Any statement that may throw an Exception must be enclosed in a try block.B. Any statement that may throw an Error must be enclosed in a try block.C. Any statement that may throw an RuntimeException must be enclosed in a try block.D.No exception are subclass of Error.Answer:A。