What will be the output of the following Java code? [code] int arr[] = new int [5]; System.out.print(arr); [/code]

Quốc Ân

New member
What will be the output of the following Java code?
Code:
    int arr[] = new int [5];
    System.out.print(arr);
A. 0
B. value stored in arr[0]
C. 00000
D. Class name@ hashcode in hexadecimal form
 
Answer: d
Explanation: If we trying to print any reference variable internally, toString() will be called which is implemented to return the String in following form:
classname@hashcode in hexadecimal form
 

Tìm kiếm

Back
Top