How would you implement this Java class?

We’re hiring a new Java developer and decided to start by asking them to write code instead of the usual Q&A.

Recently we needed to add an hourly scheduler to our sliding window data aggregator and decided this would be a good test to see how people think and code.

We gave our candidates the following class skeleton to complete.  As you can see, it has two parts.  A constructor that takes in a variable number of minutes-past-the-hour arguments.   And a method that returns the next occurrence given a fixed point in time.

We asked our candidates to compete the code and make all the tests in the main method pass.

Here’s the full listing.  How would you implement it?

 

Happy coding!

About Dele Taylor

We make Data Pipeline — a lightweight ETL framework for Java. Use it to filter, transform, and aggregate data on-the-fly in your web, mobile, and desktop apps. Learn more about it at datapipeline.io.