हिंदी

What will be the output of the given Java code after the calculation [note the data types]? double kv = Math.abs(Math.min(Math.floor(9.9), Math.ceil(9.9))−Math.round(24.6)); System.out.println

Advertisements
Advertisements

प्रश्न

What will be the output of the given Java code after the calculation [note the data types]?

double kv = Math.abs(Math.min(Math.floor(9.9), Math.ceil(9.9))−Math.round(24.6)); 

System.out.println ("KV=“ +kv);

योग
Advertisements

उत्तर

Math.floor(9.9): Rounds downward to the nearest mathematical integer, resulting in 9.0.

Math.ceil(9.9): Rounds upward to the nearest mathematical integer, resulting in 10.0.

Math.min(9.0, 10.0): Compares the two values and returns the smaller one, which is 9.0.

Math.round(24.6): Rounds to the closest integer value, which results in 25 (returned as a long).

(9.0 − 25): The long value 25 is implicitly promoted to a double (25.0) for the subtraction. Thus, 9.0 − 25.0 evaluates to −16.0.

Math.abs(−16.0): Returns the absolute (positive) value of the argument, which is 16.0. This final result is stored in the double variable kv.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४६]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 1 Revision of Class 9 Syllabus
Exercises | Q 5. (x) | पृष्ठ ४६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×