ICSE Class 10 Computer Applications Question 14 of 32

Input in Java — Question 14

Back to all questions
14
Question

Question 14

Write a line of code that:

i. Creates a Scanner object named scanner to be used for taking keyboard input.

Answer
Scanner scanner = new Scanner(System.in);

ii. Uses the object scanner to read a word from the keyboard and store it in the String variable named stg.

String stg = scanner.next();