Complete the code below to create an object of Scanner class:

Scanner sc = ____ Scanner(__________);

Views 11

Answer:

To complete the code for creating an object of the Scanner class, you need to import the Scanner class and use the new keyword to instantiate it. Here is the completed code:


import java.util.Scanner;

Scanner sc = new Scanner(System.in);

In this code:

  • import java.util.Scanner; imports the Scanner class from the java.util package.
  • new Scanner(System.in) creates a new Scanner object that reads input from the standard input stream (System.in).

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.