Computer Science, asked by 9drollno42shreyaverm, 1 month ago

What will be the output of the following Java program? class dynamic { public static void main(String args[]) { double a, b; a = 3.0; b = 4.0; double c = Math.sqrt(a * a + b*b); System.out.println(c); } }
5.0
25.0
7.0
Compilation Error​

Answers

Answered by nagrenikita769
1

Answer is the option no. 1) 5.0

Answered by purveshKolhe
4

\huge{\green{\boxed{\mathfrak{\red{ answer : }}}}}

Full côde::

class dynamic {

       public static void main(String args[]) {

              double a, b;

              a = 3.0;

              b = 4.0;

              double c = Math.sqrt(a * a + b*b);

              System.out.println(c);

       }

}

Output::

5.0

Logic::

==> The program declares two doubles where 3.0 and 4.0 are stored.

==> We evaluate the Math.sqrt() method where we find 5 as output, but as it is stored in double data type, it gives 5.0 as output.

==>Math.sqrt() method finds square root of the given argument.

I hope that my answer helps you....

Similar questions