ICSE Class 10 Computer Applications Question 3 of 14

Mathematical Library Methods — Question 3

Back to all questions
3
Question

Question 3

What is wrong with the following statements? Explain.

i. result = (5/10) * Math.sqrt( a );

Answer

(5/10) will lead to integer division as both numerator and denominator are integers. So result of (5/10) will be 0 instead of 0.5 and the entire expression will always result in 0.

ii. result = math.sqrt(b * b - 4 * a * c) / ( 2 * a );

math should be written as Math. As Java is case-sensitive so it treats math and Math differently.