Ask Question
2 July, 05:05

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.)

+1
Answers (1)
  1. 2 July, 07:16
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers