Question: Java. Strings Topic: Using String Objects Fill in the blanks in the program below as follows: (a) declare the variable town as a reference to
Java. Strings Topic: Using String Objects Fill in the blanks in the program below as follows: (a) declare the variable town as a reference to a String object and initialize it to "Anytown, USA". (b) write an assignmentstatement that invokesthe length method of the string class to find the length of the college String object and assigns the result to the stringLength variable (c) complete the assignmentstatementso that change1 containsthe same characters as college but all in upper case (d) complete the assignmentstatementso that change2 is the same as change1 except all capital O's are replaced with the asterisk (*) character. (e) complete the assignmentstatementso that change3 is the concatenation of college and town (use the concat method of the String class rather than the + operator)
// **************************************************
// StringPlay.java //
// Play with String objects
// **************************************************
public class StringPlay {
public static void main (String[] args) {
String college = new String ("PoDunk College");
________________________________;// part (a)
int stringLength;
String change1, change2, change3; ;
________________________________________;// part (b)
System.out.println (college + " contains " + stringLength + " characters.");
change1 = _______________________ ; // part (c)
change2 =________________________ ; // part (d)
change3 = _______________________ ; // part (e)
System.out.println ("The final string is " + change3);
}
}
Sample Output : PoDunk College contains 14 characters. The final string is PoDunk CollegeAnytown, USA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
