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
Q40: Insert the missing code in the following
Q41: The Scanner class's _ method is used
Q42: Consider the following code snippet: Scanner in
Q43: Consider the following code snippet. Scanner in
Q44: Consider the following code snippet: Scanner in
Q46: Which String class method will remove spaces
Q47: Which of the following statements about white
Q48: Select an expression to complete the following
Q49: Consider the following code snippet: Scanner in
Q52: The _ method of the Character class
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents