- Consider The Following Class Called Safe Public Class Safe Private String S Public Safe S Null Public 1 (139.54 KiB) Viewed 31 times
Consider the following class, called Safe: public class Safe { private String s; } } public Safe() { s = null; } public
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Consider the following class, called Safe: public class Safe { private String s; } } public Safe() { s = null; } public
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.");