1(xviii)
The output of the below statement is:
System.out.println("I said, \"It\'s wise to obey elders.\"");
- (a)I said, 'It is wise to obey elders.'
- (b)I said, "It's wise to obey elders."
- (c)I said, It's wise to elders.
- (d)"'It's wise to obey elders.'"
Show SolutionHide Solution↓
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."