This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Sequence Of events by JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sequence Of events by JVM" Watch "Sequence Of events by JVM" New topic
Author

Sequence Of events by JVM

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
What is the sequence of Events taken by JVM for the follwing line of Code ??

int[] a= new int[6];

OPTION 1

1) Refernce Variable a is created first and is initializes to NULL.
2) An array object is created.
3) Information abt how to access that object is then put into the refernce variable.

Option 2

1)) An array object is created.
2) Refernce Variable a is created first and is initializes to NULL.
3) Information abt how to access that object is then put into the refernce variable.


Please explain also ???

SCJP 6.0 96%

(Connecting the Dots ....)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

The results from "java -p Test":
I'm no expert in reading this, but to me, it looks like the array is created first, then the variable is created.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sequence Of events by JVM
 
Similar Threads
Uni JAVA Exam Monday HELP!!
Sun Cirtification
Object Referencing
Multi dimension array confusion
chapter 3 in K&B Book