Menu
Question Index
...

What will be the output of the following program?

import static java.lang.Math.sqrt;
import static java.lang.Math.pow;
class StrikesAndStrokes
{

    public static void main(String[] args) {
        double x = 64.0;
        double y = sqrt(x);
        double z = pow(y);
        double m = pow(y, 2.0);
        System.out.print(x == z ? "Strike " : "Stroke ");
        System.out.print(y + " ");
        System.out.print(m == x ? "Strokes " : "Strikes ");
        System.out.print(m + " ");
    }

    public static double pow(double in) {
        return in * in;
    }

    public static double sqrt(double in) {
        return in / 2;
    }
}


Stroke 32.0 Strikes 64.0
Strike 8.0 Strokes 64.0
Stroke 32.0 Strikes 1024.0
Compilation Error

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App