Menu
Question Index
...

What will be the output of the following program?

public class TrainLength {

    public static void main(String[] args) {
        double platformCrossingTimeInSecs = 100.0;
        double poleCrossingTimeInSecs = 50.0f;
        double platformLengthInMeters = 200;
        double trainLength = platformLengthInMeters * poleCrossingTimeInSecs / platformCrossingTimeInSecs - poleCrossingTimeInSecs;
        System.out.printf("Train Length In Meters = %2.2f", trainLength);
    }
}


Train Length In Meters = 50.00
Train Length In Meters = 200
Train Length In Meters = 200.00
Some other output or Compilation Error

Doubts

Problems

Topic: Java Formatting Numbers

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App