Multiple choice

What is the output of the given java code?

public class HelloWorld
{
public static void main(String []args)
{
System.out.println( Math.round(Math.hypot(4+1,9-1)));
}
}

  1. 13

  2. 9

  3. 12

  4. 16

  5. 22

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct answer. The hypot() method in java takes two arguments as hypot(x,y) and it evaluates the expression :-   sqrt(x^2 +y^2). So, this will find sqrt(5,8) which comes out to be 9.433, so now the round() function will convert it to the nearest integer value, which is 9. So, this is the correct choice.