233k views
1 vote
What is output given the user input? >three blind mice System.out.print("Enter info: "); Scanner keyboard = new Scanner(System.in); String info = keyboard.nextLine(); Scanner inputScnr = new Scanner(info); int item1 = inputScnr.nextInt(); String item2 = inputScnr.next(); String item3 = inputScnr.next(); System.out.println(item1 + " " + item2 + " " + item1); A. blind mice3 B. 3 mice C. 3 blind miceD. Error: input mismatch exception

1 Answer

3 votes

Answer:

Probably would be D.

In the print statement...

System.out.println(item1 + " " + item2 + " " + item1)

this would mean the pattern of the output is "ABA". There is no answer that matches that pattern.

We would see a number at the start, something in the middle and then the number again at the end. Because this is not an option in our answers, by process of elimination, we can determine that the only answer which must be correct is D.

Somewhere along there is also input mismatch exception apparently.

User FJSevilla
by
5.2k points