What will be the output of the following Java program? [code] class Output { public static void main(String args[])

Đạt Michio

New member
What will be the output of the following Java program?
Code:
    class Output 
    {
        public static void main(String args[]) 
        {
            double x = 3.14;  
            int y = (int) Math.toDegrees(x);
            System.out.print(y);
        }
    }
A. 0
B. 179
C. 180
D. 360
 
Answer: b
Explanation: 3.14 in degree 179.9087. We usually take it to be 180. Buts here we have type casted it to integer data type hence 179.
Output:
Code:
$ javac Output.java
$ java Output
179
 

Tìm kiếm

Back
Top