Menu
Topics Index
...
`

Creating Class with multiple methods1724


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating Class with multiple methods1724
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;
    }
}

A. Stroke 32.0 Strikes 64.0
B. Strike 8.0 Strokes 64.0
C. Stroke 32.0 Strikes 1024.0
D. Compilation Error
Topic: Java Multiple Methods In One Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Answer is D,
Compilation Error Because pow(y) method should have two operations or arguments.

Posted by Amar Kumar Biradar    2013-08-22 14:54:20


D is the correct answer becuse threre is no method in Math class as pow which accepts one integer arguement

Posted by Ram Reddy Bitla    2013-08-22 14:57:05


D

Posted by Gopinath Manchikanti    2013-08-22 15:02:57


Congratulations Amar Kumar Biradar. You are this dose winner. Please send us your mobile details in a private message and we will process the recharge asap.

Posted by Merit Campus    2013-08-23 10:36:21


I have got Recharge :)
Thanks Merit Campus =D

Posted by Amar Kumar Biradar    2013-08-24 06:24:05


© meritcampus 2019

All Rights Reserved.

Open In App