Challenge - 5 Problems
String Comparison Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate2:00remaining
Output of String equality check with == operator
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String a = "hello"; String b = "hello"; System.out.println(a == b); } }
Attempts:
2 left
💻 code output
intermediate2:00remaining
Output of String equality check with new operator
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String a = new String("hello"); String b = new String("hello"); System.out.println(a == b); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of equals() method for String comparison
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String a = new String("hello"); String b = "hello"; System.out.println(a.equals(b)); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of compareTo() method for String comparison
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String a = "apple"; String b = "banana"; System.out.println(a.compareTo(b)); } }
Attempts:
2 left
💻 code output
expert2:00remaining
Output of String interning and == operator
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String a = new String("test"); String b = a.intern(); String c = "test"; System.out.println(a == b); System.out.println(b == c); } }
Attempts:
2 left
