What is the result? Given: What is the result? Given: What is the result? A. true, false B. false, true C. true, true D. false, false Show Hint ← Previous question Next question →
renko B: Code: public class Equal { public static void main(String[] args) { String str1 = “Java”; String[] str2 = {“J”, “a”, “v”, “a”}; String str3 = “”; for (String str : str2) { str3 = str3+str; } boolean b1 = (str1 == str3); boolean b2 = (str1.equals(str3)); System.out.println(b1+”, “+b2); } } Output: false, true Reply
B is correct, tested it
D
B
B.
false, true
B:
Code:
public class Equal {
public static void main(String[] args) {
String str1 = “Java”;
String[] str2 = {“J”, “a”, “v”, “a”};
String str3 = “”;
for (String str : str2) {
str3 = str3+str;
}
boolean b1 = (str1 == str3);
boolean b2 = (str1.equals(str3));
System.out.println(b1+”, “+b2);
}
}
Output:
false, true