QUESTION 57Given: static void test() throws RuntimeException { try { System.out.print("test "); throw new RuntimeException(); } catch (Exception ex) { System.out.print("exception "); }} public static void main(String[] args) { try { test(); } catch (RuntimeException ex) { System.out.print("runtime "); } System.out.print("end ");} What is the result? A. test end B. Compilation fails. C. test runt..
QUESTION 56 Given: 1. public class Mud { 2. //insert code here 3. System.out.println("hi"); 4. } 5. } And the following five fragments: public static void main(String...a){ public static void main(String.* a) { public static void main(String... a) { public static void main(String[]... a) { public static void main(String...[] a) { How many of the code fragments, inserted independently at line 2, ..
QUESTION 55 Given: 1. public class Threads4 { 2. public static void main (String[] args) { 3. new Threads4().go(); 4. } 5. public void go() { 6. Runnable r = new Runnable() { 7. public void run() { 8. System.out.print("foo"); 9. } 10. }; 11. Thread t = new Thread(r); 12. t.start(); 13. t.start(); 14. } 15. } What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The c..
QUESTION 54 Given: 1. public class LineUp { 2. public static void main(String[] args) { 3. double d = 12.345; 4. // insert code here 5. } 6. } Which code fragment, inserted at line 4, produces the output | 12.345|? A. System.out.printf("|%7d| \n", d); B. System.out.printf("|%7f| \n", d); C. System.out.printf("|%3.7d| \n", d); D. System.out.printf("|%3.7f| \n", d); E. System.out.printf("|%7.3d| \..
QUESTION 53 Given: 04. import java.io.*; 05. 06. public class Talk { 07. public static void main(String[] args) { 08. Console c = new Console(); 09. String pw; 10. System.out.print("password: "); 11. pw = c.readLine(); 12. System.out.println("got " + pw); 13. } 14.} If the user types the password aiko when prompted, what is the result? A. password: got B. password: got aiko C. password: aiko got..
QUESTION 52 Given: import java.io.*; public class Forest implements Serializable { private Tree tree = new Tree(); public static void main(String [] args) { Forest f = new Forest(); try { FileOutputStream fs = new FileOutputStream("Forest.ser"); ObjectOutputStream os = new ObjectOutputStream(fs); os.writeObject(f); os.close(); } catch (Exception ex) { ex.printStackTrace(); } }} class Tree { } Wh..