Output Questions for Class 10 ICSE Computer Applications

Predict the output of the following Java program snippet:


String str = "Information Technology";
int p;
p = str.indexOf('n');
System.out.println(p);

Java

Java String Handling

40 Likes

Answer

1

Working

str.indexOf('n') will return the first index of n in str which is 1. So, the output of this program is 1.

Answered By

22 Likes