Creating and Storing Objects (Instantiation)

AP Computer Science A· difficulty 2/5

Which line creates a new <code>Scanner</code> object reading from System.in?

  • A

    Scanner s = Scanner.in;

  • B

    Scanner s = new Scanner();

  • C

    Scanner s = new Scanner(System.in);

    check_circle
  • D

    Scanner s = System.scanner;

Explanation

Constructor takes the input stream; <code>new</code> allocates the object.

Want 10 more like this — adaptive to your weak spots?

Related questions