Ask Question

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 = = " ")

+3
Answers (1)
  1. 4 April, 03:06
    0
    The correct answer to the following question is an option c) while (inputFile. hasnextInt ()).

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers