Latest Update 100% Solved
Assume that name is a variable of type String that has been assigned a value. Write an
expression whose value is a String containing the first character of the value of name. So if the
value of name were "Smith" the expression's value would be "S". ✔️✔️name.substring(0,1)
Assume that name is a variable of type String that has been assigned a value. Write an
expression whose value is a String containing the second character of the value of name. So if
the value of name were "Smith" the expression's value would be "m". ✔️✔️name.substring(1,2)
Write an expression that results in a String consisting of the third through tenth characters of
the String s. ✔️✔️s.substring(2,10)
Assume that word is a variable of type String that has been assigned a value. Write an
expression whose value is a String consisting of the last three characters of the value of word.
So if the value of word were "biggest" the expression's value would be "est".
✔️✔️word.substring(word.length() - 3,word.length())
Given three String variables that have been declared and given values, firstName, middleName,
and lastName, write an expression whose value is the initials of the three names: the first letter
of each, joined together. So if firstName, middleName, and lastName, had the values "John",
"Fitzgerald", and "Kennedy", the expression's value would be JFK". Alternatively, if firstName,
middleName, and lastName, had the values "Franklin", "Delano", and "Roosevelt", the
expression's value would be "FDR". ✔️✔️"" + firstName.charAt(0) + middleName.charAt(0) +
lastName.charAt(0)
Assume that sentence is a variable of type String that has been assigned a value. Assume
furthermore that this value is a String consisting of words separated by single space characters
with a period at the end. For example: "This is a possible value of sentence."
, Assume that there is another variable declared, firstWord, also of type String. Write the
statements needed so that the first word of the value of sentence is assigned to firstWord. So, if
the value of sentence were "Broccoli is delicious." your code would assign the value "Broccoli"
to firstWord. ✔️✔️firstWord =
sentence.substring(0,sentence.indexOf(' '));
Assume that given, middle and family are three variables of type String that have been assigned
values. Write an expression whose value is a String consisting of the first character of given
followed by a period followed by the first character of middle followed by a period followed by
the first character of family followed by a period: in other words, the initials of the name. So if
the values of these three variables were "John" "Fitzgerald" "Kennedy", then the expression's
value would be "J.F.K.". ✔️✔️given.charAt(0) + "." + middle.charAt(0) + "." + family.charAt(0) + "."
Given a String variable named sentence that has been initialized, write an expression whose
value is the the very last character in the String referred to by sentence.
✔️✔️sentence.charAt(sentence.length() - 1)
Assume that word is a variable of type String that has been assigned a value. Assume
furthermore that this value always contains the letters "dr" followed by at least two other
letters. For example: "undramatic", "dreck", "android", "no-drip".
Assume that there is another variable declared, drWord, also of type String. Write the
statements needed so that the 4-character substring word of the value of word starting with
"dr" is assigned to drWord. So, if the value of word were "George slew the dragon" your code
would assign the value "drag" to drWord. ✔️✔️drWord = word.substring(word.indexOf("dr"),4);
Write a sequence of statements that finds the first comma in the String line, and assigns to the
variable clause the portion of line up to, but not including the comma. You may assume that an
int variable pos, as well as the variables line and clause, have already been declared. ✔️✔️pos =
line.indexOf(',');
clause = line.substring(0,pos);