Question
A Java method attempts to extract a substring.
public class StringProcessor {   public String extractPart(String text, int start, int length) {     // Assume text is "HelloWorld"     // Assume start = 5, length = 6     return text.substring(start, start + length); // Potential bug here   } } If text = "HelloWorld", start = 5, and length = 6, what will be the outcome of calling extractPart(text, start, length)?Solution
Correct Answer: D (The string "HelloWorld" has length 10. start = 5, start + length = 5 + 6 = 11. substring(5, 11) attempts to access index 10, which is out of bounds as valid indices are 0-9.)
Shyam marked an article 25% above cost price and sold it for Rs. 1080 after allowing a discount of 10%. Find his profit (in Rs.).
31 kg of rice ‘A is purchased for Rs. 7/kg while 28 kg of rice ‘B’ is purchased for Rs. 8/kg. If the mixture of the both types of rice is sold at ...
Priya bought two articles for Rs. 1080. She sold one at a loss of 25% and another at a profit of 25%. If the selling price of both the articles is equal...
A bag of cost price of Rs. 8000 is marked up by a certain percentage, and a discount percent of twice the markup percent is offered on it. If there is a...
A man lost one-fourth of his initial amount in the gambling after playing three rounds. The rule of Gambling is that if he wins he will receive Rs. 1000...
A shopkeeper sells an item for ₹7200 and gains 20% on the cost price. If he sells the same item at ₹8000, what will be his percentage gain?
A shopkeeper buys 20 articles for Rs 5,000. He sells each article at 25% profit on the cost price. Due to a seasonal sale, he offers a 10% discount on t...
Selling price of article ‘A’ when sold at a profit of 20% is Rs. 150 more than its selling price when sold at a loss of 30%. If the cost price of ar...
A shopkeeper marks up the price of an article by 40% on its cost price. He then offers a discount of 10% on the marked price. If the shopkeeper still ma...
K and L invested Rs. 3200 and Rs. 2800 respectively. After 6 months, L increases his investment by Rs. 1200. If the total profit for the year is Rs. 231...