Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Programmer Certification (OCPJP)
Simple Math Expression
Joshua Fix
Ranch Hand
Posts: 57
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is killing me... I don't know if I'm tired or what. How is the output of this 7???
int i = 1; int result = 5 + i++ % 4 * i; System.out.println(result);
SCJP 5.0
Chandran Madesh
Greenhorn
Posts: 18
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, The output 7 is correct.
int i = 1; int result = 5 + i++ % 4 * i; // 1) i++ %4 = 1 (now i get increment so now i =2) 2) 1 * 2 = 2 3) 5 + 2 = 7 System.out.println(result);
the operator priority is % , * ,+ in the above code.
<b>Chandran.M<br /> <br /> <br /> Do Your Best <br /></b>
eat bricks! HA! And here's another one! And a tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Passing the method's return as argument
Putting Binary Search Tree into an array
Help with int Conversion to String
Post Operator
GCD calculation using Euclidean algorithm fails
More...