25.9k views
25 votes
Type the correct answer in the box. Spell all words correctly. Which class is required to create an object that accepts input in Java

1 Answer

12 votes

Answer:

Step-by-step explanation:

In order to ask for and accept an input in Java you first need to import the Scanner class into your file. Once you have imported this class you then need to create a Scanner object and assign it a variable. Next you would need to print to the system the question that you want the user to input an answer to. Lastly, you save the input into a string variable to use for later. An example of which can be seen in the following code...

Scanner input = new Scanner(System.in);

System.out.println("Enter an answer: ");

String answer = input.nextLine();

User Candiru
by
5.5k points