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:

Verified
Correct Answer:
Verified
Q11: Consider the following code snippet: Scanner in
Q12: Consider the following code snippet: public static
Q13: Consider the following code snippet:<br>If (in.hasNextDouble())<br>{<br>Number =
Q14: Consider the following code snippet written in
Q15: Consider the following code snippet. File hoursFile
Q17: You wish to use the Scanner class's
Q18: Insert the missing code in the following
Q19: Consider the following code snippet: Scanner in
Q20: Which method of an exception object will
Q21: Insert the missing code in the following