public static void main(String[] args) {
int[] x = new int[3];
System.out.println(“x[0] is “+x[0]);
}
}
a. The program has a syntax error because the size of the array
wasn’t specified when declaring the array.
b. The program has a runtime error because the array elements are
not initialized.
c. The program runs fine and displays x[0] is 0.
d. None of the above.
#
11. How can you get the word “abc” in the main method from the
following call?
#
12. Which code fragment would correctly identify the number of
arguments passed via the 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 – 1;
c. int count = 0; while (args[count] != null) count ++;
d. int count=0; while (!(args[count].equals(“”))) count ++;
#
13. Show the output of running the class Test in the following code
lines:
interface A {
void print();
}
class C {}
class B extends C implements A {
public void print() { }
}