1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Simora [160]
3 years ago
6

Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String contai

ning the last character of the value of name. So if the value of name were "Smith" the expression's value would be "h".Given a String variable named sentence that has been initialized, write an expression whose value is the number of characters in the Stringreferred to by sentence.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 last character of the value of name. So if the value of name were "Smith" the expression's value would be "h".
Computers and Technology
1 answer:
Stella [2.4K]3 years ago
3 0

Corrected (Modified) Question:

i. 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 last character of the value of name. So if the value of name were "Smith" the expression's value would be "h".

ii. Given a String variable named sentence that has been initialized, write an expression whose value is the number of characters in the String referred to by sentence.

Explanation of the corrected question

The whole question has been numbered (i) and (ii) just to separate or divide it into clearer sub questions.

Some parts of the question has also been removed since they are repetition of a part of the question.

Answer:

(i) name.charAt(name.length() - 1)

(ii) sentence.length()

Explanation:

No language  has been specified in the question for the code to be written in. However, I have chosen to write it in Java.

(i) In Java, to get a particular character in a string <em>str</em>, the function, charAt(x) is used, where x in the function represents the index of the character to be fetched. This is written as str.charAt(x).

In our case, x is the index of the last character in our string. To get the index of the last character in a string say <em>str</em>, the length of the string itself is used. However, indexing starts at zero. Therefore, to get the index, it will be the 1 subtracted from the length of the string as follows:

str.length() - 1

But note that, to get the length of a string, the method length() is used. For example if,

String str = "omobowale";

str.length() will return 9

Now to the question at hand, our string variable name is <em>name. </em>

Therefore to get its last character, we write:

<em>name.charAt(name.length() - 1)</em>

So if;

name = "Smith";

name.charAt(name.length() - 1) will return "h"

(ii) As explained in (i) above, to get the length (number of characters) of the variable string <em>sentence, </em>we simply write;

<em>sentence.length()</em>

<em>PS: The length of  a string is the number of characters present in the string.</em>

Hope this helps!

You might be interested in
Hey, My paperclips just stoped producing, does anyone have any idea how to start them up again?
swat32

Answer:

I have no clue how to get that working up again but how does a paperclip relate to that?

7 0
3 years ago
Which of the following techniques has to do with how the people who make the commercial manipulate the way it looks?
marta [7]
<span>a. Omission
_________
</span>
6 0
4 years ago
Una pregunta cuales son los ataques de Sindel que por favor y me lo diga gracias
Len [333]
I do not know spanish please say in english
5 0
4 years ago
PLEASE HELP ASAP!!!!111 Read "Teenagers are rewriting the rules of the news" (find it somewhere and answer questions below)
Ilya [14]

Answer:

Sorry, we picked up your question late. There are a lot of questions, and every now and then some misses out. And I am sure you will understand. However, the cool thing is your answers are correct. I read the complete article on young adults or teenagers and found the same. And I am sure you will agree with the facts, and use its best meaning in your own life. I am, however, listing below all the answers for your complete satisfaction. And I congratulate you, you are up with the correct list of answers.

The answer to the First question is:

B. the description of how influencers follow young social media users"

Second question answer is

C. Andrew Yang

And the third question answer is:

C. Teens and young adults consume and spread news information through social media.

And I am sure you must have liked this article. Article reading is a good habit. You should always start a day by reading one article online or in newspaper.

Explanation:

Please check the answer section.+

4 0
3 years ago
Which call of the function correctly follows the instructions laid out in the api?.
Juliette [100K]

Answer:

MoveElement("button1", "down", 25); This function finds the minimum number in a list.

Explanation:

Hope this helps

3 0
3 years ago
Other questions:
  • What is the device that allows users to manipulate data by controlling an onscreen pointer
    5·2 answers
  • The development team recently moved a new application into production for the accounting department. After this occurred, the Ch
    7·1 answer
  • PLEASE HELP!!!!!!!!!!!!!!!!!!!!
    13·1 answer
  • How do i cancle my account on brainly
    11·1 answer
  • Which of the following is NOT true about simple machines?
    10·1 answer
  • 1. Choose a real or made up company, and describe at least three ways in which the company uses technology. (1-3 sentences. 3.0
    13·1 answer
  • 3<br> Select the correct answer.<br> What is the output of the following HTML code?<br>Please
    8·2 answers
  • 1. Who is known as the father of a computer?​
    12·2 answers
  • In the context of in-house software development options, a firm that enhances a commercial package by adding custom features and
    5·1 answer
  • Wi-Fi Protected Access (WPA) fixes critical vulnerabilities in the earlier wired equivalent privacy (WEP) standard. Understandin
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!