File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a[i]=i=9 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a[i]=i=9" Watch "a[i]=i=9" New topic
Author

a[i]=i=9

lucy hu
Ranch Hand

Joined: Aug 21, 2000
Posts: 60
Hi, all, this one is from the JavaQuest Mock Exam,
What happens during execution of the following program?
1. public class OperandOrder {
2. public static void main(String args[]) {
3. int i=0;
4. int a[] = {3,6};
5. a[i] = i = 9;
6. System.out.println(i + " " + a[0] + " " + a[1]);
7. }
8. }
I'm confused about the answer: 9, 9, 6
could anybody explain how "a[i] = i = 9" is excuted?
Lucy
Cherry Mathew
Ranch Hand

Joined: Dec 26, 2000
Posts: 159
it will be 9,6,6
just check once more
itz bcos when we assign first
a[0] = i = 9; is done
then a[0] = 9;
is done
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
the order od evaluation is left 2 right whereas for assignment the order of execution is right 2 left .
Hope this is clear
------------------
"Winners don't do different things
They do things differently"


"Winners don't do different things<br /> They do things differently"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a[i]=i=9
 
Similar Threads
question about OperandOrder
Sudoku Solver
question from KAM
SoDuko puzzle
A funny program I just write,Check!