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

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 = 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");

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: