Question: In the following code what will be printed? String s1= cat; String s2= cat; if(s1 == s2) { System.out.println(s1 + is the same string as


In the following code what will be printed? String s1= "cat"; String s2= "cat"; if(s1 == s2) \{ System.out.println(s1 +" is the same string as " +s2); \} else if (s1.equals(s2))\{ System.out.println(s1+" is the same word as " +s2); \} else \{ System.out.println("The two strings are different"); \} A. cat is the same string as cat B. cat is the same word as cat C. The two strings are different D. There is a syntax error and the code will not compile. E. cat is the same string as cat cat is the same word as cat Review Check to review before finishing (will be flagged in Table of Contents) Question 2 of 4 (worth 4 points) In the following code what will be printed? String s1= "cat"; String s2= "Cat"; if(s1 == s2) \{ System.out.println(s1+" is the same string as " +s2); \} else if (s1.equals(s2))\{ System.out.println(s1 + " is the same word as " +s2); \} else \{ System.out.println("The two strings are different"); \} A. cat is the same string as Cat B. The two strings are different C. There is a syntax error and the code will not compile. D. cat is the same string as Cat cat is the same word as Cat E. cat is the same word as Cat In the following code, what will print? double x=2.5; double y=2.52; double tolerance =0.01; if (Math.abs (xy)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
