Answer:
a) "Quit"
c) "Q only
Explanation:
Given
String s = "Go";
while ((!s.equals("q"))&& (!s.equals(""))) {
System.out.println("In loop");
s = scnr.next();
}
Required
What input causes another execution
Analyzing the while condition
while ((!s.equals("q"))&& (!s.equals("")))
This can be split into:
!s.equals("q")) && (!s.equals(""))
Meaning
When s is not equal to "q" and when s is not an empty string
In other words,
the loop will be executed when user input is not "q" and user input is not empty.
So, from the list of given options: The loop both will be executed when:
a) Input is "Quit"
c) Input is Q only
Input of q will terminate the loop, hence b and d are incorrect