Concerning Q35 of Mock Exam 2 in Jiris:
What is the output of trying to compile and run the following code?
public class Test035
{
public static void main(
String args[])
{
System.out.print(" ".indexOf("") + " " );
System.out.print("".indexOf("") + " " );
System.out.print("Java".indexOf("") + " ");
System.out.println("Java".indexOf("J") );
}
}
A: 0 0 0 0
B: 0 0 0 1
C: 0 0 1 1
D: 0 1 1 1
E: 1 1 1 1
Answer is: A
Does someone have an explanation for the first 3 zeros? What if it was lastIndexOf instead of indexOf?