What will be the output on executing the following code...

Q

What will be the output on executing the following code...

✍: Guest

A

What will be the output on executing the following code.
public class MyClass {
public static void main (String args[] ) {
int abc[] = new int [5];
System.out.println(abc[0]);
}
}

A Error array not initialized
B 5
C 0
D Print some junk characters

C.

Here it will not give any compile time or runtime error because we have declared and initialized the array properly. Event if we are not assigning a value to the array, it will always initialized to its defaults. So the array will be initialized with values zero.

2013-03-11, 1882👍, 0💬