Question
class Input_Output {
public static void main(String args[]) throws IOException {
string str;
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
do {
str = (char) obj.readLine();
System.out.print(str);
} while(!str.equals("strong"));
}
}
What is the output of this program if input given is "Hello stop World"?
class Input_Output {
public static void main(String args[]) throws IOException {
string str;
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
do {
str = (char) obj.readLine();
System.out.print(str);
} while(!str.equals("strong"));
}
}
Answer: Option D
Was this answer helpful ?
"stop" will be able to terminate the do-while loop only when it occurs singly in a line.
"Hello stop World" does not terminate the loop.
Output:
$ javac Input_Output.java
$ java Input_Output
Hello stop World
Was this answer helpful ?
Submit Solution