Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from Dan's exam. 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from Dan Watch "Question from Dan New topic
Author

Question from Dan's exam.

sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
I got this doubt after taking up a test on the topic 'operators'
i = 1+2%3*4
the ans:i=9
Though i answered it corrct,, i got the doubt when i revisited the code.
According to operator precedence, the order of operator precedence starting from the highest is *,/,%. But this is not applicable to the above expression. So i am confused whether we have to follow the order of precedence or do we have any other simple rule?..
pl. clarify
-sanjana
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
The operators you mentioned * / % have the same level of precedence and are evaluated left to right in the code.
sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
Yes I realised it sometime after posting the question. Anyway thanks for your reply.
-sanjana
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question from Dan's exam.
 
Similar Threads
Double wrapper class doubt?
?: doubt
EL doubt
doubt in jls - order of Evaluation
doubt in jls - order of evaluation