nerdexam
Oracle

1Z0-819 · Question #57

Which code fragment prints 100 random numbers?

The correct answer is D. D. var r = new Random(); DoubleStream.generate(r::nextDouble).limit(100).forEach(System.out::print). See the full explanation below for the reasoning.

Question

Which code fragment prints 100 random numbers?

Options

  • AA. var r = new Random(); new DoubleStream.of(r.nextDouble()).limit(100).forEach(System.out::print);
  • BB. DoubleStream.generate(Random::nextDouble) .limit (100).forEach(System.out::print);
  • CC. DoubleStream.generate(Random.nextDouble).limit(100).forEach(System.out::print);
  • DD. var r = new Random(); DoubleStream.generate(r::nextDouble).limit(100).forEach(System.out::print);

How the community answered

(29 responses)
  • A
    10% (3)
  • B
    3% (1)
  • C
    7% (2)
  • D
    79% (23)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice