What is the result? 10/29/2018 – by Mod_GuideK 2 Given the code fragment: What is the result? A. true true B. true false C. false false D. false true SHOW ANSWERSCorrect Answer: C Explanation/Reference: Explanation/Reference: Download Printable PDF. VALID exam to help you PASS.
C public static void main(String[] args) { String s =” “; s.trim(); System.out.println(s.equals(“”)+” “+s.isEmpty()); } false false 3 1 Reply
Answer C: the str.trim() got ignored (i.e. has not been saved to any variable. So str remains as it is. An empty space in a string (i.e. ” “) is actually filled with a blank character, meaning that this String is not empty. 9 Reply
C
public static void main(String[] args) {
String s =” “;
s.trim();
System.out.println(s.equals(“”)+” “+s.isEmpty());
}
false false
Answer C:
the str.trim() got ignored (i.e. has not been saved to any variable. So str remains as it is.
An empty space in a string (i.e. ” “) is actually filled with a blank character, meaning that this String is not empty.