Menu
Topics Index
...
`

Rounding Function


If you need explanation Read this topic

If you need Answer Take test on this topic

Rounding Function
What will be the output of the following program?
public class AbsoluteMethod {
    public static void main(String[] args) {
        int i = 12;
        long l = -10;
        double d = 95.53;
        float f = 0.62f;
        System.out.print("i: " + Math.abs(i));
        System.out.print(" s: " + Math.abs(l));
        System.out.print(" d: " + Math.abs(d));
        System.out.print(" f: " + Math.abs(f));
    }
}

A. i: 12 s: 10 d: 95.53 f: 0.62
B. i: 12 s: -10 d: 95.5 f: 0.6
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 A... Math.abs gives the absolute value of the variable..

Posted by Om Prakash Om    2014-05-13 08:39:54


answer is c or d   because the varibale s is not declared

Posted by Maryam Maryam    2014-05-13 08:57:01


Ans A .....abs function gives the absolute value therefore no negative num

Posted by Manasa Jyothi Sree    2014-05-13 09:03:27


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

Posted by Merit Campus    2014-05-14 04:03:07


© meritcampus 2019

All Rights Reserved.

Open In App