You can add some print statements to see what is happening and answer your question. For example, I added a few and got the following as a result. From that you can see it's not as simple as you're imagining.
Enter your firstName and sureName :
John a
Name = John a
Enter your firstName and sureName :
John b
Name = John b
Enter your firstName and sureName :
John z
Name = John z
Enter your firstName and sureName :
John d
Name = John d
Enter your firstName and sureName :
Array of names = [John a, John b, John z, John d, null, null]
s1 = John b
s2 = John a
s1 = John z
s2 = John b
s1 = John d
s2 = John z
s1 = John d
s2 = John b
s1 = John d
s2 = John z
s1 = null
s2 = John d
Exception in thread "main" java.lang.NullPointerException
at TestClass$1.compare(TestClass.java:16)
at TestClass$1.compare(TestClass.java:1)
at java.util.TimSort.binarySort(TimSort.java:265)
at java.util.TimSort.sort(TimSort.java:190)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at TestClass.sortNames(TestClass.java:9)
at TestClass.main(TestClass.java:60)