Menu
Question Index
...

What will be the output of the following program?

class SumOfDoubles
{
    public static void main(String args[])
    {
    
        double d1 = 0.7;
        double d2 = 77.0/1000.0;
        double d3 = d1 * 10;
        double d4 = 77E+2;
        double d5 = 77E-5;

        double sum = d1 + d2 + d3 + d4 + d5;
        
        System.out.println("sum = " + sum);
    }
}


sum = 7707.77777
sum = 7777.77777
Compilation errors.
sum = 7770.77077

Doubts

Problems

Topic: Basic Arithmetic Operators In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App