• Register
0 votes
192 views

Problem:

Which of the following will open a file named MyFile.txt and allow you to read data from it?

a.	File file = new File("MyFile.txt");

b.	Scanner inputFile = new Scanner("MyFile.txt");

c.	File file = new File("MyFile.txt");
Scanner inputFile = new Scanner(file);

d.	PrintWriter inputFile = new PrintWriter("MyFile.txt");

Does any one know correct file name?

5.4k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

 

Correct file name is :

File file = new File("MyFile.txt");
Scanner inputFile = new Scanner(file);

Hope you got it.

10.5k points