Menu
Topics Index
...
`

Find price


If you need explanation Read this topic

If you need Answer Take test on this topic

Find price
What will be the output of the following program?
public class Price {
    public static void main(String[] args) {
        int quantity = 3;
        float type1 = 2.5F;
        double type2 = 12.3;
        System.out.println("Type1 price " + Math.scalb(type1, quantity));
        System.out.println("Type2 price " + Math.scalb(type2, quantity));
    }
}

A. Type1 price 7.5
Type2 price 36.9
B. Type1 price 20.0
Type2 price 98.4
C. Compilation Error
D. Runtime Error
Topic: Java Math Class - java.lang.Math

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is B math.scalb performs value(type1)*2^quantity: 2.5*8=20 ,12.3*8=98.4

Posted by Teja Potlapally    2014-03-11 13:24:54


Ans is B since The java.lang.Math.scalb(float f,int scaleFactor) returns f x 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.

Posted by Bharath Yelchuri    2014-03-11 13:30:45


Ans is B

Posted by Sai Abhishek    2014-03-11 13:31:34


Congratulations Teja Potlapally. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-12 04:24:46


© meritcampus 2019

All Rights Reserved.

Open In App