Answer is A. Because String str is "Sweet Sweat" not "Sweet sweat"
String str="Sweet Sweat";
String str2=str.trim().charAt(6)+" " + str.indexOf("Sw",1);
System.out.println(str2); // S 6
The answer is the letter C, it is a little complicated but analyzing the code we managed to answer the question ignoring the difficult part. Looking at "str.indexOf("Sw",1)" we can see that it wants to know what is the position of the first "Sw" that appears in the String content and we can see that it is at position 1. The only alternative that prints the 1 in the second position of the string "str2" is the C option.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Sudhakar_Senthilkumar
1 week, 6 days agoMPignaProTech
2 months, 3 weeks agoakbiyik
2 years, 1 month agocarloswork
2 years, 1 month agoUAK94
2 years, 3 months agoiSnover
2 years, 3 months agoJess1985B
1 year, 1 month ago