KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

Predict the output of the following:

System.out.println(Math.round(-18.51));

Java

Java Math Lib Methods

ICSE

35 Likes

Answer

-19

Working

Math.round method rounds off its argument to the nearest mathematical integer and returns its value as an int or long type. At the mid-point i.e. when the decimal part of the argument is 0.5, Math.round method rounds up to the higher integer. In this case, the nearest integer to -18.51 is -19 so it is the output.

Answered By

21 Likes