Part 1: Exercises (5 pts) Given the String object calledmyString with the value
ID: 668510 • Letter: P
Question
Part 1: Exercises (5 pts)
Given the String object calledmyString
with the value "Now is the time for the birthday party"
answer the following questions.
#1: Write a statement that will print the number of characters in the string.
#2: Write a statement that outputs the character at index 16
#3: Write a statement that outputs the position of the word “for” in the sentence.
#4: Write a statement that outputs the sentence in uppercase letters
#5: Write a statement that uses the original string to extract the new string "birthday party" and prints it to the screen
Explanation / Answer
1.
int a=calledmyString.length();
2.
char c= calledmyString.cahrat(16);
3.
int p = getPosition("for",calledmyString);
4. String s = calledmyString.toUpperCase();
5.
System.out.println(Str.substring(25, 14) );