Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What does the Scanner class do?
Think about how we read user input in Java.
Name one method of the Scanner class.
Consider how you check for the next line of data.
What class is typically used to read files in Java?
Think of the class that reads line by line.
True or False: You must close a Scanner after use.
What do we always emphasize after usage?
Write a program using Scanner that reads a file called 'data.txt' and counts the number of lines in the file, also handling the possible exception if the file doesn't exist.
Consider how you would typically read each line in a loop.
Discuss how your program would behave if you forgot to use the try-catch block while opening a file within the Scanner class.
Think of it like planning for bumps on the road; how would you manage unexpected issues?
6 more questions in this section. Enroll free to practise them all.
Enroll free