Wednesday, April 8, 2009

Puzzle 14 – Multiplication or Addition.

Language – Java Type – Concept Last date 12-Apr-2009 12:00 p.m. IST Points 2

Mathematical rules dictate that multiplication takes precedence over addition. It’s called BODMAS. Somehow the Java folks don’t seem to agree. But then maybe you could give me a better explanation for this anomaly?

package com.twisters;

public class MulOrAdd {
public static void main(String[] args) {
int x=5;
*= 5+2;
"Value of X is : "+x);

Got an answer? Why don’t you leave it here.

No comments:

Post a Comment

Solution for this question?