What is the result of the following when called as java mypkg.Main?
package mypkg; /* www.ja va2 s . c o m*/ import java.util.*; public class Main { ? public static void main(String[] args) { args = new String[] {"0", "1", "01", "10" }; ? Arrays.sort(args); System.out.println(Arrays.toString(args)); } }
B.
While no arguments are passed from the command line.
This doesn't matter because the main()
method redefines the args
array.
Remember that String values sort alphabetically rather than by number.
01 sorts before 1, and Option B is correct.