Java - IO - Interview Questions and Answers on Scanner

Q1.  What is Scanner class used for ? when was it introduced in Java ?

Ans. Scanner class introduced in Java 1.5 for reading Data Stream from the imput device. Previously we used to write code to read a input using DataInputStream. After reading the stream , we can convert into respective data type using in.next() as String ,in.nextInt() as integer, in.nextDouble() as Double etc 

Q2. Which interfaces are implemented by Scanner?

Ans.[, Closeable, AutoCloseable, Iterator<String>]

Q3. Which is the Parent Class of Scanner class?

Ans.java.lang.Object

Q4. What is the package name for Scanner class?

Ans.api.java.util