Ask Question
15 February, 03:13

Declare a Scanner reference variable fileInput, and assign it a newly created Scanner object that is associated with a file named "data1". (Do not concern yourself with any possible exceptions here- - assume they are handled elsewhere.)

+2
Answers (1)
  1. 15 February, 06:35
    0
    Scanner fileInput = new Scanner (new File ("data1"));

    Explanation:

    In JAVA Scanner class is used to get input from the user.

    In order to use this class an instance of this class is created also called an object.

    Here the fileInput is a reference variable which is also called instance variable used to access a Scanner object.

    new keyword is used here to create an instance or object of Scanner class.

    File is a class which works with files and directories. So new File ("data1") is used to create an object of File and data1 is passed to it because in order to create an instance of the class, a string, which can be a name of file or an object is passed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Declare a Scanner reference variable fileInput, and assign it a newly created Scanner object that is associated with a file named "data1". ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers