Home » JAVA Programming » Java Basic » Question
  1. Which of the following is good coding practice to determine oddity?
    i)
    public boolean Calc(int n)
    {
    return (n & 1)!= 0;
    }

    ii)
    public boolen Calc(int n)
    {
    return n % 2 == 1;
    }
    1. i
    2. ii
    3. option (i) causes compilation error
    4. option (ii) causes compilation error
    5. None of these
Correct Option: A

Arithmetic and logical operations are much faster than division and multiplication.



Your comments will be displayed only after manual approval.