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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post 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 31 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.");
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply