11
Loading subject content…
Loading subject content…
Loading practice questions…
What is the output of the following program?
public class Main {
public static void main(String[] args) {
java.util.List<Integer> nums = java.util.List.of(1, 2, 3);
int s = 0;
for (int n : nums) s += n;
System.out.println(s);
}
}What is the output of the following program?
class Main {
static <T extends Comparable<T>> T max(T a, T b) { return a.compareTo(b) >= 0 ? a : b; }
public static void main(String[] args) { System.out.println(max(3, 9) + " " + max("pear", "apple")); }
}