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
Consider the following program segment in which the statements are jumbled.
Choose the correct order of statements to calculate and return the factorial of 4.for(k = 1; k <= 4; k++) → 1 return fa; → 2 long fa = 1, k; → 3 fa *= k; → 4- 1, 2, 3, 4
- 3, 1, 4, 2
- 3, 1, 2, 4
- 1, 3, 2, 4
Write the Java expression to find the product of square root of P and the square root of Q using the methods of Math class.
Write the Java statement for creating an object named 'sifra' of the class 'Robot', which takes three double parameters.
Convert the given loop into exit-controlled loop.
int a, b; for(a = 10, b = 1; a >= 1; a -= 2){ b += a; b++; } System.out.print(b);