Challenge - 5 Problems
String Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate2:00remaining
Output of substring and length methods
What is the output of the following Java code?
Java
public class Main { public static void main(String[] args) { String s = "HelloWorld"; System.out.println(s.substring(2, 7) + " " + s.length()); } }
Attempts:
2 left
💻 code output
intermediate2:00remaining
Result of toUpperCase and trim methods
What will be printed by this Java program?
Java
public class Main { public static void main(String[] args) { String s = " java Programming "; System.out.println(s.trim().toUpperCase()); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of replace and equals methods
What is the output of this Java code snippet?
Java
public class Main { public static void main(String[] args) { String s1 = "apple"; String s2 = s1.replace('p', 'b'); System.out.println(s2.equals("abble")); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of indexOf and charAt methods
What will this Java program print?
Java
public class Main { public static void main(String[] args) { String s = "Programming"; int index = s.indexOf('g'); char c = s.charAt(index + 1); System.out.println(c); } }
Attempts:
2 left
💻 code output
expert3:00remaining
Final value of string after chained methods
What is the final output of this Java code?
Java
public class Main { public static void main(String[] args) { String s = " Java123 Programming456 "; s = s.trim().replaceAll("\\d", "").toLowerCase(); System.out.println(s); } }
Attempts:
2 left
