Can u guess the output??

Read the followng code and determine the output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class Array{

    public void process()
    {
        int i[]={1,3,4,5};
        System.out.println(i);
    }

    public static void main(String args[])
    {
        new Array().process();
    }
}

// log on to www.comprogzz.in to learn programming in Java

[I@224a9dcd (Memory location in Heap) Error!! 1345 "asfaf"

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Shahid Champ
Sep 16, 2014

i is reference of array so it will print the reference hexadecimal code.........

Well, Arrays are referred as OBJECTS in java where they occupy heap memory which holds their values on a particular address . So if we reach 7th line while executing the program we actually try printing i 's memory which seems to print its values but it actually prints its alphanumeric address. In Short any object in java holds heap memory that's logically divided into addresses while printing it refers to its class address.

Debajyoti Ghosh
May 13, 2014

It prints the base address of Array i...

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...