Quiz: toUpperCase and toLowerCase
Consider the variable declaration
String river = "Mississippi";
What is the return value of the call river.toUpperCase()? Remember to enclose strings in quotes. |
"MISSISSIPPI" |
All letters are uppercase. |
What is the return value of the call river.toLowerCase()? |
"mississippi" |
Only the first letter has changed. |
What is the return value of the call river.toUpperCase().toLowerCase()? |
"mississippi" |
That is the same as "MISSISSIPPI".toLowerCase(). |
Bonus: What is the value of river after these calls? |
"Mississippi" |
The original String object has not changed. The method calls produce new strings. |