Computer Applications
Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String starting from a specific index.
- (A) is true and (R) is false.
- (A) is false and (R) is true.
- Both (A) and (R) are true and (R) is a correct explanation of (A).
- Both (A) and (R) are true and (R) is not a correct explanation of (A).
Java String Handling
3 Likes
Answer
(A) is false and (R) is true.
Reason — In Java, Strings are immutable, so the substring() method does not modify the original String, it returns a new String, making Assertion (A) false. However, the method does extract a part of the String starting from a specific index, which makes Reason (R) true.
Answered By
1 Like
Related Questions
An array with 3 elements is arranged in a ascending order as follows:

Name the technique used:
- Bubble sort
- Linear Search
- Selection sort
- Binary Search
The sales made by 5 salesmen selling 5 products is stored in a two-dimensional array of integer data type. How many bytes does the array occupy?
- 25
- 200
- 50
- 100
In constructor overloading, all constructors should have the the same name as of the class but with a different set of …………… .
- Access specifiers
- Classes
- Return type
- Parameters
Rewrite the following program segment using a for loop.
int a = 5, b = 10; while (b > 0) { b -= 2; } System.out.println(a * b);