62.4k views
5 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 == " ")

User Swille
by
8.8k points

1 Answer

3 votes

Answer:

The correct answer to the following question is an option c) while (inputFile.hasnextInt()).

Step-by-step explanation:

hasnextint() is the function of the scanner class which is "java.util.Scanner".

This method returns the boolean value so the data type of this method is boolean.

Integer values of radix are assumed only when a next token is in the Scanner input and it returns output True.

The other options are false because the input file can be null and the end of file is not equal to the input file and the next line is equal to the space and also the other options are not the object of the scanner class.

User Eric Dand
by
8.7k points

No related questions found