Question: Look at the following code: String str1 = To be, or not to be; String str2 = str1.replace('o', 'u'); System.out.println(str1); System.out.println(str2); You hear a fellow

Look at the following code: 

String str1 = "To be, or not to be";
String str2 = str1.replace('o', 'u');
System.out.println(str1);
System.out.println(str2);

You hear a fellow student claim that the code will display the following: 

Tu be ur nut tu be
Tu be ur nut tu be

Is your fellow student right or wrong? Why?

Step by Step Solution

3.27 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution The student is wrong The cod... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Starting Out With Java From Control Structures Questions!