Advertisements
Advertisements
Question
Write the output of the following String method:
String x= “ talent” ; String y=”matrix” ;
System.out.print(x.substring(3).concat(y.substring(3)));Code Writing
Advertisements
Solution
'entrix"
Explanation:
The method x.substring(3) extracts the characters of x starting from index 3 up to the end, resulting in "ent". Similarly, y.substring(3) extracts the characters of y from index 3 to the end, giving "rix". These two strings are then joined together using the concat() method.
shaalaa.com
Is there an error in this question or solution?
2024-2025 (March) Official Board
