What is the result? Given the code fragment: What is the result? Given the code fragment: What is the result? A. true true B. true false C. false false D. false true Show Hint ← Previous question Next question →
Sucuk C = correct. String is immutable so trim will not do anything. Also, the string is not empty, Java will reserve space in the heap. Reply
renko Answer: C package q070; public class Test { public static void main(String[] args) { String str = ” “; str.trim(); System.out.println(str.equals(“”) +” “+ str.isEmpty()); } } /*Output false false */ Reply
C = correct. String is immutable so trim will not do anything. Also, the string is not empty, Java will reserve space in the heap.
Answer: C
package q070;
public class Test {
public static void main(String[] args) {
String str = ” “;
str.trim();
System.out.println(str.equals(“”) +” “+ str.isEmpty());
}
}
/*Output
false false
*/
C