1Z0-829 Working with Streams and Lambda Expressions Practice Question
Which THREE of the following are valid ways to create an infinite stream? (Choose three.)
⚠ Common exam trap
The trap here is that candidates mistakenly think `IntStream.range(0, Integer.MAX_VALUE)` is infinite because the upper bound is large, but it is actually a finite stream that terminates after producing Integer.MAX_VALUE elements.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
IntStream.generate(() -> 0)
`IntStream.generate(() -> 0)` uses a supplier that always returns 0, producing an infinite stream of zeros. The `generate` method creates an unordered infinite stream by repeatedly invoking the supplier, with no termination condition.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
IntStream.generate(() -> 0)
Why this is correct
Generates an infinite IntStream of zeros.
- ✓
Stream.iterate(1, n -> n+1)
Why this is correct
Creates an infinite sequential stream starting from 1, incrementing by 1.
- ✗
IntStream.range(0, Integer.MAX_VALUE)
Why it's wrong here
This is a finite stream (though very large) because range excludes the end value.
- ✓
Stream.generate(Math::random)
Why this is correct
Generates an infinite stream via a Supplier.
- ✗
Stream.of(1,2,3)
Why it's wrong here
This creates a finite stream with three elements.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.