Return a random object from the stream

Suppose you have a stream object. This stream object ONLY has two methods. They are:
HasNext() - returns a boolean if there are more items in the stream
GetNext() - returns the next item in the stream
Given a stream such as this one, return a random object from it. No, the stream cannot be reset.

top 5
42 months ago
Small pic dmc binary stream

Submit your solution
This challenge has received 29 submissions
Top 5 share 750
150 Square pic hoa3 University of California at San Diego
150 T University of Michigan
150 R Rochester Institute of Technology
150 Square pic a17f956af0cc98ef09029fe181a1d598 Wesleyan University
150 Square pic befunky underpainting 1 University of Toronto
Contact Us!
Share your thoughts, ideas and stories with 300,000 peers Write for our Blog