Quiz Space

Programming Concepts using Java · Quiz 2 · 16 Mar 2025 · January 2025 term

Question 11: Method Stream.iterate(e, f) returns an infinite sequenti…

Question 11

+7 marksOne correct option

Method Stream.iterate(e, f) returns an infinite sequential ordered Stream produced by iterative application of a function f to an initial element e, producing a Stream consisting of e, f(e), f(f(e)), ...
Based on the above information, consider the code given below, and answer the question that follows.

java
import java.util.stream.*;
public class Test {
public static void main(String[] args) {
Stream.iterate(50, p -> p - 5)
.map(p -> p * 2)
.filter(p -> p % 4 == 0)
.limit(4)
.forEach(p -> System.out.print(p + " "));
}
}

What will the output be?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 11 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 16 Mar 2025, in the January 2025 term (IIT M DIPLOMA AN EXAM QDD2 16 Mar 2025). It carries 7 marks.

More questions from this paper

  1. Q1Consider the Java code given below that prints the maximum element of a set. From among the options, identify the appro…
  2. Q2Consider the Java code given below. Choose the correct option.
  3. Q3The following code maps a set of patients to the number of visits they have made to a hospital and categorizes the pati…
  4. Q4Consider the code given below. What will the output be?
  5. Q5Consider the following Java code. Choose the correct option to be filled in place of LINE 1 so that the output is:\ [Ta…
  6. Q6Consider the following Java code. Choose the correct option.
  7. Q7Consider the Java code given below. Choose the correct option.
  8. Q8Consider two Java files located in different packages as shown below. A.java B.java Choose the correct option.
  9. Q9Consider the Java code given below. Identify the first assert statement that throws the AssertionError when the class i…
  10. Q10Consider the Java code given below. Identify the appropriate option to fill in place of LINE 1 such that the output is:…
  11. Q12Consider the Java code given below. What will the output be?
  12. Q13Consider the Java code given below. Choose all the options which can be used in place of ARG in LINE 1 so that the code…
  13. Q14The Java code given below should print the names of water filters whose flow rate falls within the range of 5.0 to 15.0…
  14. Q15Consider the Java code given below. How does class MarksExample look after type erasure?