Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.floor(x);
System.out.print(y);
}
}

What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.floor(x);
System.out.print(y);
}
}
a) 0
b) 3
c) 3.0
d) 4

Answer: b
Explanation: double floor(double X) returns a largest whole number less than or equal to variable X. Here the smallest whole number less than 3.14 is 3.

Join The Discussion