Question: Which of the following is the correct syntax to declare a Scanner to read the file example.txt in the current directory? a. Scanner input =

Which of the following is the correct syntax to declare a Scanner to read the file example.txt in the current directory?

a. Scanner input = new Scanner("C:\example.txt");

b. Scanner input = new Scanner(new File("example.txt"));

c. Scanner input = new File("\\example.txt");

d. File input = new Scanner("/example.txt");

e. Scanner input = new Scanner("C:/example.txt");

Step by Step Solution

3.25 Rating (183 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Correct syntax to declare a ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!