KnowledgeBoat Logo
|

Computer Applications

Write the output of the following String method:

String x = "talent";
String y = "matrix";
System.out.println(x.substring(3).concat(y.substring(3)));

Java

Java String Handling

7 Likes

Answer

entrix

Working

  • x.substring(3) returns the substring of "talent" from index 3 onwards, i.e., "ent".
  • y.substring(3) returns the substring of "matrix" from index 3 onwards, i.e., "rix".
  • The concat() method joins both substrings: "ent" + "rix" = "entrix".

Answered By

4 Likes


Related Questions