In one of the mock test, I came across these question where I have some doubts: Which code fragments would correctly identify the number of arguments passed via command line to a Java application, excluding the name of the class that is being invoked? A.int count = args.length; B.int count = args.length - l; C.int count=0; while (args [count]!=null) count ++; D.int count=0; while (!(args[count].equals(""))) count ++;} Answer given is A. I tried C and that also seem to give me the correct answer. Select all valid answers. a) an array extends Object b) an array extends Cloneable c) an array implements Cloneable d) an array extends primitive types like int, char, byte e) None Answer given: a,c Why c?? I checked the Java docs and Array exetends Object but does not implement. Can someone explain whether I am right or wrong.
I didn't try option "c" but I would think it would throw an exception. If you had 1 arguemnt on the command line, then args would not be null and count would get incremented to 1, but the next time through the loop, arg would throw an IndexOutOfBounds exception because there is no args. Bill