Java Scanner Class Aptitude Questions and Answers.

This section contains Aptitude Questions and Answers on Java Scanner Class, method of Scanner Class are used to read values from the user.



List of Java Scanner Class Aptitude Questions

1) Which Scanner class method is used to read integer value from the user?
  1. next()
  2. nextInteger()
  3. nextInt()
  4. readInt()

2) Which Scanner class method is used to read string value from the user?
  1. next()
  2. nextString()
  3. nextLine()
  4. Both 1 and 3

3) Which method does not store string value after space?
  1. next()
  2. nextString()
  3. nextLine()
  4. Both 1 and 3

4) Which is the correct syntax to declare Scanner class object?
  1. Scanner objectName= Scanner();
  2. Scanner objectName= new Scanner();
  3. Scanner objectName= Scanner(System.in);
  4. Scanner objectName= new Scanner(System.in);

5) Consider the following object declaration statement
Scanner objectName= new Scanner(System.in);
What is System.in in this declaration?
  1. Class which point input device
  2. Reference to Input stream
  3. Reference to Computer System
  4. None of these