Advertisements
Advertisements
प्रश्न
What will be the output of the given Java code after the calculation [note the data types]?
double fw = Math.pow (3,Math.ceil(2.12));
System.out.println ("FW=" + fw);
योग
Advertisements
उत्तर
Math.ceil(2.12);
- The
Math.ceil()method rounds a number upward to its nearest mathematical integer. - 2.12 rounded up becomes 3.0 (returned as a double).
Math.pow(3,3.0);
- This calculates 33 (3 × 3 × 3)
- The result is 27, but since it
Math.pow()always returns a double, it evaluates to 27.0. - FW = 27.0
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
