Question

The String Class: 1a.) Given the following delcaration: String modification1; Write a statement that stores the...

The String Class:

1a.) Given the following delcaration:

String modification1;

Write a statement that stores the uppercase equivalent of the string object called "city" in modification1.

1b.) Write a statement that declares a String variable named city. The variable should be initialized with the string literal "Los Angeles".

1c.) Given the following declaration:

int stringSize;

Write a statement that stores the length of the string object called "city" in stringSize.

1d.) Given the following declaration:

char oneChar;

Write a statement that stores the third character of the string object called "city" in oneChar.

1e.) Given the following delcaration:

String modification2;

Write a statement that replaces all the characters 'e' by # in the string object 'city', and stores the modified string in the modification2.

1f.) Given the following delcaration:

String modification3;

Write a statement that stores the lowercase equivalent of the string object 'city' in modification3.

Homework Answers

Answer #1

1.a:
modification1 = city.toUpperCase();
1.b:
String city = "Los Angeles"
1.c:
//to get size we can use length() method
stringSize = city.length();

1.d:
oneChar = city.charAt(2);
// 3rd will be stores at index 2 as indexes starts from 0

1.e:
modification2= city.replaceAll("e","#");
1.f:
modification3 = city.toLowerCase();

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
write a statement that declares char variable named gender initialized to the character m in c++...
write a statement that declares char variable named gender initialized to the character m in c++ additionally, What is the value of number after the following code executes? int a=5; int b=10; int number = a++ + b++; lastly, The break; is required in every case block of a switch statement true or false and A default block is required in every switch statement true or false
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods....
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods. Remember that all the String methods are accessors. They do not change the original String. If you want to apply multiple methods to a String, you will need to save the return value in a variable. Complete the class by doing the following: + Print the word in lowercase + Replace "e" with "3" (Use the unmodified variable word) + Print the changed word...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
Part 1 Given the following code: public class MyClass { private double score; private String studentID;...
Part 1 Given the following code: public class MyClass { private double score; private String studentID; //code of the class ..... } //end of MyClass Code a default constructor and an overloaded constructor of MyClass that will assign values to its two instance fields: Please write in JAVA Part 2 Continue from question about, code an mutator of instance field called studentID:
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...