+ 13
Module To Accept User Input???
What module must be imported to accept user input in Java? A. java.util B. java.io Why the answer is B?? Why it isn't A??
11 Answers
+ 33
it depends on your requirements. So, if you are ok with Scanner, you will use java.util package. But in a big commercial projects, most of times you will use FileInputStream which is in java.io package.
+ 16
Technically, both answers are correct. According to your question either one can be used to take user input (java.util.Scanner as well as java.io.BufferedReader.)
Just for a note: BufferedReader is used with InputStreamReader)
+ 16
InputStream must be imported to accept user input in java and InputStream is from java.io.
System.in is an InputStream so you don't really need to import java.io.
btw io means input output so it would make sense for B to be the answer.
+ 12
The question is flawed. Either it should had been a multiple correct answer or only one option of both should had been provided.
The answer is both (java.io.BufferedReader and java.util.Scanner) btw.
+ 10
Oh thanks @Mickel SĂĄnchez!
Of course, we need to report it. Never knew that it was a challenge question, my bad... đ
+ 9
Thanks Devđ
+ 7
@Dev, I think this is actually a question about a challenge
So, report the challenge could be useful to modify the question correctly. At the moment it is quite diffuse and contains errors as already indicated
+ 6
As they said, both are correct (maybe you should notify that, so the quiz is modified)
+ 2
I remember that the user input is made with java.util.Scanner
and you make an object with the Scanner class or something like that.
+ 1
The only difference is when you import only scanner , itâs only imports Scanner. If you import whole thing thing util.*; , it imports everything from Util.
0
You can use it by adding import java.util.*;
Or
Import java.util.Scanner;