Java code find output: public class Demo { public static void main(String[] args) { double values[]={-2.3, -1.0, 0.25, 4}; int cnt = 0; for (int…

Java code find output:

public class Demo {
    public static void main(String[] args) {
        double values[]={-2.3, -1.0, 0.25, 4};
        int cnt = 0;
        for (int x=0; x < values.length; x++) {
            if(Math.round(values[x]+.5) == Math.ceil(values[x])) {
                ++cnt;
            }
        }
        System.out.println("same results" + cnt + " time(s)");
    }
}

From the BUET MSC (ICT) May 2019 – Written exam, question 3 of 20.

More from this paper