DEVFYI - Developer Resource - FYI

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

Java Interview Questions and Answers (part 3)


(Continued from previous question...)

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

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);
}
}

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

D

It will print some junk characters to the output. 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.

(Continued on next question...)

Other Interview Questions