Q. What does this sequence of statements print? String msg = “The number of char
ID: 3927619 • Letter: Q
Question
Q. What does this sequence of statements print?
String msg = “The number of characters in newCar is”;
String newCar = ”GMC”; int numberOfCharacters = newCar.length();
String carUpperCase = newCar.toUpperCase();
System.out.print(newCar);
System.out.println(carUpperCase);
System.out.print(msg);
System.out.println(newCar.length());
newCar.replace(“C”,”U”);
newCar.replace(“M”,”E”);
newCar.replace(“G”,”S”);
System.out.print(“Welcome to : ”);
System.out.println(newCar);
/*System.out.println(“Good luck”);
System.out.println(“to all students”);*/
I need the answer to be copied to Word not a picture.
Explanation / Answer
String msg = "The number of characters in newCar is";
String newCar = "GMC"; int numberOfCharacters = newCar.length();
String carUpperCase = newCar.toUpperCase();
System.out.print(newCar);
System.out.println(carUpperCase);
System.out.print(msg);
System.out.println(newCar.length());
newCar.replace("C","U");
newCar.replace("M","E");
newCar.replace("G","S");
System.out.print("Welcome to : ");
System.out.println(newCar);
/*System.out.println("Good luck");
System.out.println("to all students");*/
OUTPUT :
GMCGMC
The number of characters in newCar is3
Welcome to : GMC
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.