Practice mode Java

What is the output of the Java code int a = new int; System.out.println(a);?

Correct answer D. 0

Explanation

Array components are always given default values when the array is created, and for int that value is 0. Java never exposes uninitialised memory. A null default would apply only to arrays of a reference type, such as String[]. The number 3 is the array length, not the content of any element.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.