227k views
2 votes
Assume that input file references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached?

a. while (inputFile != null)
b. while (!inputFile.EOF)
c. while (inputFile.hasnextInt())
d. while (inputFile.nextLine == " ")
e. while (inputFile.hasnextInt())

User Ndrplz
by
7.0k points

1 Answer

6 votes

Answer:

The answer is letter C

Step-by-step explanation:

The correct way to read data from the file until the end of the file is reached is while (inputFile.hasnextInt())

User Jellyfication
by
8.3k points