Menu
Question Index
...

What will be the output of the following program?

public class Pythagoras {

    public static void main(String[] args) {
        double sinTheta = Math.sin(30);
        double cosTheta = Math.cos(30);
        double tanTheta = Math.tan(30);
        double sum = sinTheta * sinTheta + cosTheta * cosTheta;
        System.out.print(sum + " " + isEqual(tanTheta, sinTheta / cosTheta) + " ");
        System.out.print(isEqual(1 / 2, sinTheta) + " ");
        System.out.print(isEqual(Math.sqrt(3) / 2, cosTheta) + " ");
        System.out.print(isEqual(1 / Math.sqrt(3), tanTheta) + " ");
    }

    public static boolean isEqual(double one, double two) {
        return (Math.abs(one - two) < 0.0001);
    }
}


1.0 true false true true
1.0 true false false false
1.0 true true true true
1.0 false false false false
Some other output or Compilation error or Runtime error

Doubts

Problems

Topic: Java Math Class - java.lang.Math

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App