Page 1 of 1

Consider the following class, called Safe: public class Safe { private String s; } } public Safe() { s = null; } public

Posted: Fri Jul 08, 2022 6:43 am
by answerhappygod
Consider The Following Class Called Safe Public Class Safe Private String S Public Safe S Null Public 1
Consider The Following Class Called Safe Public Class Safe Private String S Public Safe S Null Public 1 (139.54 KiB) Viewed 33 times
Consider the following class, called Safe: public class Safe { private String s; } } public Safe() { s = null; } public void safeMethod() { } What is the exact output of the following fragment of code? Safe s = new Safe(); try { System.out.println("Starting safeMethod"); System.out.println("Length is: " + s.length() ); } System.out.println("Trying"); s.safeMethod(); System.out.println("After the call"); catch(Exception e) { System.out.print("Caught Exception "); System.out.println( e.getMessage()); } finally { System.out.print("All done.");