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

  • (A) next()
  • (B) nextLine()
  • (C) Both A and B.
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B.
Explanation: 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).
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).

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
249
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
96%
Success Rate