Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the String variable called word, initialized to “Supercalifragilisticexpia

ID: 3733655 • Letter: G

Question

Given the String variable called word, initialized to “Supercalifragilisticexpialidocious”
write the String method that will achieve the answer to the following questions:

Write the instruction to get the length of word. _________________

Write the instruction to get “fragil” from the word above. ______________________

Write the instruction to get “docious” from the word above. ________

Write the instruction that will return the last char of ‘r’ from the word above. ______

Write the instruction that will print out the first location of the letter ‘e’ _________

Write the instruction that will print out the second location of the letter ‘e’ _______

Write the instruction that will print out the word all in upper case ________

Write the program that contains all 7 of these questions, debug it, and test it.

Explanation / Answer

Write the instruction to get the length of word. _________________
Answer:
word.length();

Write the instruction to get “fragil” from the word above. ______________________
Answer:
word.substring(10,15);

Write the instruction to get “docious” from the word above. ________
Answer:
word.substring(27)


Write the instruction that will return the last char of ‘r’ from the word above. ______
Answer:
word.charAt(10);

Write the instruction that will print out the first location of the letter ‘e’ _________
Answer:
word.charAt(3);

Write the instruction that will print out the second location of the letter ‘e’ _______
Answer:
word.charAt(20);

Write the instruction that will print out the word all in upper case ________
Answer:
word.toUpperCase();

Test.java

public class Test {

public static void main(String[] args) {

String word = "Supercalifragilisticexpialidocious";

System.out.println(word.length());

System.out.println(word.substring(9,15));

System.out.println(word.substring(27));

System.out.println(word.charAt(10));

System.out.println(word.charAt(3));

System.out.println(word.charAt(20));

System.out.println(word.toUpperCase());

}

}

Output:

34
fragil
docious
r
e
e
SUPERCALIFRAGILISTICEXPIALIDOCIOUS

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote