Which of the following pieces of code are considered to be a correct Java code?
Explanation
Unlike C/C ++, a limited number of arithmetic expressions can be used as operators in Java: assignment, increment / decrement (++/--), method call, object creation. Everything else is not available.

YEAP, that was strange explanation! Fixed, thanks)

2016 Feb 2, 4:26:37 PM

Say please, why Math.abs(1) + Math.abs(2); is not a correct STATEMENT? I have entered code sample: int i = Math.abs(1) + Math.abs(2); in method main and program runs without problems.

2016 Feb 1, 10:42:28 AM

+Vitaliy Kotov Thanks a lot! Fixed)

2015 Aug 4, 2:47:06 PM

... "Math.abs(1);" is a correct *STATEMENT*, and "Math.abs(1) + Math.abs(2);" is not a correct *STATEMENT*.

2015 Jul 31, 5:12:51 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes