हिंदी

Given: double a = - 8.35; double p = Math.abs(Math.floor(a)); What will be the final value stored in the variable p? - Computer Applications

Advertisements
Advertisements

प्रश्न

Given: double a = - 8.35;

double p = Math.abs(Math.floor(a));

What will be the final value stored in the variable p? 

विकल्प

  • 9.0

  • 8.0

  • 7.0

  • 8.5

MCQ

उत्तर

9.0

Explanation:

The Math.floor() method returns the greatest double number that is less than or equal to the argument and equals a mathematical integer. As -9.0 is the largest mathematical integer less than -8.35, it is returned in this circumstance. Math.abs() returns the absolute value of its argument, so the result is 9.0. The expression is resolved as follows:

p = Math.abs(Math.floor(a));

p = Math.abs(Math.floor(-8.35));

p = Math.abs(-9.0);

p = 9.0

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.07: Mathematical Library Methods - EXERCISES [पृष्ठ ८०]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.07 Mathematical Library Methods
EXERCISES | Q I. 1. | पृष्ठ ८०
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×