English

What will be the output of the given Java code after the calculation [note the data types]? double cy = Math.ceil (Math.cbrt(0.125), Math.sqrt(0.64)); System.out.println("CY=" +cy);

Advertisements
Advertisements

Question

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

double cy = Math.ceil (Math.cbrt(0.125), Math.sqrt(0.64));

System.out.println("CY=" +cy);

Short Answer
Advertisements

Solution

intended to use Math.max() or Math.min() (which do accept two arguments), here is how they would evaluate:

Inner Functions:

  • Math.cbrt(0.125) (cube root of 0.125) = 0.5
  • Math.sqrt(0.64) (square root of 0.64) = 0.8

Hypothetical Output:

  • If it were Math.max(0.5, 0.8), the output would be: CY = 0.8.
  • If it were Math.min(0.5, 0.8), the output would be: CY = 0.5.

shaalaa.com
  Is there an error in this question or solution?
Chapter 1: Revision of Class 9 Syllabus - Exercises [Page 46]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 1 Revision of Class 9 Syllabus
Exercises | Q 5. (ix) | Page 46
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×