Home » 
        MCQs » 
        Java MCQs
    
        
    Method used to take a string as input in Java?
    
    
    
    12. Method used to take a string as input in Java?
    
        - next()
 
        - nextLine()
 
        - Both A. and B.
 
        - None of these
 
    
    Answer: B) 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).