Computer Applications
The output of the below statement is:
System.out.println("I said, \"It\'s wise to obey elders.\"");
- I said, 'It is wise to obey elders.'
- I said, "It's wise to obey elders."
- I said, It's wise to elders.
- "'It's wise to obey elders.'"
Java
Values & Data Types Java
5 Likes
Answer
I said, "It's wise to obey elders."
Reason — In Java, the backslash \ is used as an escape character. The statement uses escape sequences:
\"to include double quotes inside a string.\'to include a single quote inside a string.
So the output preserves both the double quotes around "It's wise to obey elders." and the apostrophe in It's.
Hence, the output is: I said, "It's wise to obey elders."
Answered By
2 Likes
Related Questions
Which of the following converts "25" to 25.0?
- Double.Parsedouble("25")
- Double.parse("25")
- Double.parseDouble("25")
- Double.parseDouble(25)
Consider the program segment:
int p = 0; for(p = 4; p > 0; p -= 2); System.out.print(p); System.out.println(p);The above statement will display:
- 42
- 4200
- 0
0 - 00
What is the output of the statement given below?
"ANGER".compareTo("ANGEL")- 3
- -6
- 6
- 0
Consider the following program segment in which the statements are jumbled.
Choose the correct order of statements to calculate and return the factorial of 4.for(k = 1; k <= 4; k++) → 1 return fa; → 2 long fa = 1, k; → 3 fa *= k; → 4- 1, 2, 3, 4
- 3, 1, 4, 2
- 3, 1, 2, 4
- 1, 3, 2, 4