Question

In: Computer Science

Assume that the following variables have been declared: String a = “Ready, Set, Go!”; String b...

Assume that the following variables have been declared:
String a = “Ready, Set, Go!”;
String b = a.substring(5, 10);
char b1 = b.charAt(2);

Evaluate the following expression:
1. Character.isLowerCase(b1)

2. b1 + 5

3. b + 5

4. Character.toLowerCase(b1)

5. a.charAt(2 + a.indexOf(“e”))

Solutions

Expert Solution

a = "Ready, Set, Go!"
b starts from 5 till 9
so b=", Set"
b1 is character in b at index 2,
so b="S"

1. Character.isLowerCase(b1)
This returns false is b is upper case("S")

2. b1 + 5
This will add 5 to the ascii value of character in b1
the ascii value of S is 83, so this returns 88.

3. b+5
This will simply append 5 at the end of string b
this returns ", Set5"

4. Character.toLowerCase(b1)
This converts S to s and returns s

5. a.charAt(2 + a.indexOf(“e”))
a.indexOf("e") returns 1
a.charAt(2+1) return d


Related Solutions

Assume we have two string variables: Shakespeare byte 'Brevity is the soul of wit' and
​Assembly Language   Assume we have two string variables: Shakespeare byte 'Brevity is the soul of wit' and Poet byte 'The problem is not in the stars but within ourselves'   Write a AL program that will interchange the contents of the two variables.
Assume you have the following set of job evaluation factors: A. Educational Requirements B. Experience C....
Assume you have the following set of job evaluation factors: A. Educational Requirements B. Experience C. Responsibility D. Mental Effort E. Physical Effort F. Working Conditions G. Work Leadership A B C D E F G Admin. Secretary I 4 5 3 2 1 1 1 Technician II 4 2 1 2 1 2 1 Engineer I 5 1 2 3 2 2 1 Engineer IV 6 4 4 5 1 1 3 Accounting Leader 5 3 5 4 1...
Go through this test a few times to learn about output. Get graph paper ready. Assume...
Go through this test a few times to learn about output. Get graph paper ready. Assume we rent a floral booth which will sell flower bouquets. We only have a fixed $10 table rent (FC) but have variable costs depending on how many bouquets we make. These bouquets are a commodity and the market price is $6 (P). Watch for how variable costs VC go down, then up. Also, what marginal cost MC is. Question 5 (1 point) If we...
It is the beginning of September, and you have been offered the following deal to go...
It is the beginning of September, and you have been offered the following deal to go heli-skiing. If you pick the first week in January and pay for your vacation now, you can get a week of heli-skiing for $1,700. However, if you cannot ski because the helicopters cannot fly due to bad weather, there is no snow, or you get sick, you do not get a refund. There is a 50% probability that you will not be able to...
1. Assume that total has already been declared as a double variable and received a value,...
1. Assume that total has already been declared as a double variable and received a value, and discountRate has been declared as a double variable, you don’t need to declare them again. You write one if statement (not multiple individual if statements) for following requirements. when total is less than 50, set discountRate to 0.0; when total is equal to or greater than 50 and less than 100, set discountRate to 0.05; when total is equal to or greater than...
Ready-Set-Go, Ltd. distributes suitcases to retail stores and extends credit terms of 1/10, n/30 to all...
Ready-Set-Go, Ltd. distributes suitcases to retail stores and extends credit terms of 1/10, n/30 to all of its customers. At the end of June, Ready-Set-Go's inventory consisted of suitcases costing £1,200. During the month of July, the following merchandising transactions occurred. July 1 Purchased suitcases on account for £1,620 from Trunk Manufacturers, FOB destination, terms 2/10, n/30. The appropriate party also made a cash payment of £100 for freight on this date. 3 Sold suitcases on account to Satchel World...
Explain in detail, in your own words, what the following statements mean (suppose variables are declared...
Explain in detail, in your own words, what the following statements mean (suppose variables are declared and initialized: x declared as double, ch declared as char, s declared as string). Q3.1 ifstream input("numbers.txt"); Q3.2 ++num; Q3.3 static_cast(x); Q3.4 bool b2 = 0; Q3.5 srand(time(0)); Q3.6 floor(x); Q3.7 isupper(ch)); Q3.8 cout << s[0] << endl; Q3.9 cout << setw(9) << x; Q3.10 cout << setprecision(3) << x << "\n ";
We have a data set named "pp123" with the following variables, "highestgradecompleted", "earn," "age", and "agesquared."...
We have a data set named "pp123" with the following variables, "highestgradecompleted", "earn," "age", and "agesquared." Draft an R script with the following specifications (we aren't given the data file) and are asked just for the script. Regress "earn" on "highestgradecompleted," "age," and "agesquared" such that it evaluates whether highestgradecompleted" has a discrete effect at particular thresholds: having 12 years of schooling ("highestgradecompleted" values equaling 12); having less than 12 ("highestgradecompleted" values < 12); and having more than 12 years...
How far do you think doctors should go to save someone who has been declared brain-dead?...
How far do you think doctors should go to save someone who has been declared brain-dead? How should this be determined? Explain
Finally, assume you currently have $200,000 that you are ready to invest for retirement. In addition,...
Finally, assume you currently have $200,000 that you are ready to invest for retirement. In addition, you plan to save $6,000 per year at the end of each year for years 1-9 $25,000 at the end of year 10 $9,000 per year at the end of each year for years 11-22 Assuming you earn 8% as an annual rate of return, how much will you have 22 years from today when you retire?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT