Solved

Assume That InputFile Is a Scanner Object Used to Read

Question 16

Multiple Choice

Assume that inputFile is a Scanner object used to read data from a text file which contains a number of lines. Each line contains an arbitrary number of words, with at least one word per line. Select an expression to complete the following code segment, which prints the last word in each line. while (inputFile.hasNextLine() )
{
String word = "";
String line = inputFile.nextLine() ;
Scanner words = new Scanner(line) ;
While (_________________)
{
Word = words.next() ;
}
System.out.println(word) ;
}


A) words.hasNext()
B) words.hasNextInt()
C) line.hasNext()
D) inputFile.hasNext()

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions