Menu
Topics Index
...
`

Finite Infinite


If you need explanation Read this topic

If you need Answer Take test on this topic

Finite Infinite
What will be the output of the following program?
public class FiniteInfinite {
    public static void main(String[] args) {
        try {
            double d = Double.POSITIVE_INFINITY;
            System.out.print(d + " # ");
            double d3 = Double.NEGATIVE_INFINITY;
            System.out.print(d3 + " # " + (d == d3) + " # ");
            double d2 = 22 / 0.0;
            System.out.print(d2 + " # ");
            double d4 = -22 / 0.0;
            System.out.print(d4 + " # ");
            double d5 = 22 / 0;
            System.out.print(d5 + " # ");
        } catch (ArithmeticException ae) {
            System.out.print("Ex");
        }
    }
}

A. Infinity # Infinity # true # Infinity # Infinity # Ex
B. Infinity # -Infinity # false # Ex
C. Infinity # -Infinity # false # Infinity # -Infinity # Ex
D. Compilation Error
Topic: Java isInfinite() And isNaN() Methods In Double Class

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:C d=Infinity,d3=-Infinity,"false,"d2=Infinity,d4="-Infinity". because of 22/0 raises arithmetic exception display enters into catch block  finally display  "ex"

Posted by Indra Chereddy    2014-06-11 08:55:04


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

Posted by Merit Campus    2014-06-12 03:57:41


© meritcampus 2019

All Rights Reserved.

Open In App