Computer Science, asked by RENJITAKRISHNAN, 5 months ago

String wd = “welcome”;
char ch=wd.charAt(wd.length()-2);
System.out.print(“Value = ” + ch);​

Answers

Answered by kamalrajatjoshi94
2

Answer:

Steps how it executed:

First String variable (wd) is declared

wd.charAt returns a char value.

wd.length returns a int value and returns the length of String I.e. 7

Length-2 means 5(letter o) but as we know that the index of String which is an array starts with 0 so 5 means 6 th index which is 'm' hence answer is m.

Attachments:
Similar questions