Which Of The Following Is Good Coding Practice To Determine #1160
Which of the following is good coding practice to determine oddity?<br /> i)</p> <pre><code class="language-java" line="1"> public boolen abc(int num) { return num % 2 == 1; } </code></pre> <p>ii)</p> <pre><code class="language-java" line="1"> public boolean xyz(int num) { return (num & 1)!= 0; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs128 Java. It can also be found in gs gs128 Java Autoboxing - Java Coding Best Practices - Quiz No.1.
Which of the following is good coding practice to determine oddity?
i)
i)
public boolen abc(int num) { return num % 2 == 1; }
ii)
public boolean xyz(int num) { return (num & 1)!= 0; }
i
ii
(i) causes compilation error
(ii) causes compilation error