Home / Programming MCQs / JAVA MCQs / Question

R

Ram Sharma • 188.81K Points
Coach

Q.  Method used to take a string as input in Java?

(A) next()
(B) nextLine()
(C) Both A and B.
(D) None of these
Explanation by: Team MCQ Buddy
The next() method can read the input only till the space. It can't read two words separated by space, while the nextLine() reads input including space between the words (that is, it reads till the end of line \n).

You must be Logged in to update hint/solution

Discusssion

Login to discuss.