Menu
Question Index
...

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");
        }
    }
}


Infinity # Infinity # true # Infinity # Infinity # Ex
Infinity # -Infinity # false # Ex
Infinity # -Infinity # false # Infinity # -Infinity # Ex
Compilation Error

Doubts

Problems

Topic: Java isInfinite() And isNaN() Methods In Double Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App