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 that an int variable age has been declared and already given a value and assume...
Assume that an int variable age has been declared and already given a value and assume that a char variable choice has been declared as well. Assume further that the user has just been presented with the following menu: S: hangar steak, red potatoes, asparagus T: whole trout, long rice, brussel sprouts B: cheddar cheeseburger, steak fries, cole slaw (Yes, this menu really IS a menu!) Write some code that reads a single character (S or T or B) into...
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...
Evaluate the truth values of the following conditions given the values of the declared variables. NOTE:...
Evaluate the truth values of the following conditions given the values of the declared variables. NOTE: Conditions formed using relational or equality operators (>, <, >=, <=, ==, !=) are relational conditions. Conditions formed using logical operators [&& (AND), || (OR), & (boolean AND), | (boolean inclusive OR), ^ (boolean exclusive OR) are complex conditions. Variables boolean gameLoss = false; int points = 15; boolean championship = false; Conditions: Evaluate then Indicate the truth value produced by the relational conditions...
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...
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...
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...
For C++ Assume that word is a variable of type string that has been assigned a...
For C++ 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...
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 ";
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT