Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops is the correct way to read data from the file until the end of the file is reached?

Respuesta :

Answer:

while(inputFile.hasNext()) { //some code here  }

Explanation:

Even though you did not provide the options, here is how it should look like.

It is known in the question that there is an object called inputFile. To be able to read all the data from a file in Java, you need to use hasNext() function with the object. inputFile.hasNext() enables you to read the data in a file.

while(inputFile.hasNext()) {   } enables you to loop through the file while it has something to read in a file.