Fidelity Investments interview question

Write a Java function that prints all the prime numbers up to a specified value and explain its time complexity.