Question 17
Back to Exercise
What is the output of the following Java program?
import java.util.List;
public class Main {
public static void main(String[] args) {
List<String> langs = List.of("C", "C++", "Java");
System.out.println(String.join(" | ", langs));
System.out.println("=".repeat(5) + String.join("", "a", "b", "c").toUpperCase() + "=".repeat(5));
System.out.println(String.join(",", List.of()).isEmpty());
}
}
- A C | C++ | Java =====ABC===== true Correct
- B C|C++|Java =====abc===== true
- C C | C++ | Java | =====ABC===== false
- D [C, C++, Java] =====ABC===== true
Correct Answer: Option A
join puts the separator only between elements; joining an empty list gives an empty string.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!