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
1
Answer is the option no. 1) 5.0
Answered by
4
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
Social Sciences,
18 days ago
English,
18 days ago
Physics,
1 month ago
Political Science,
1 month ago
English,
9 months ago
Chemistry,
9 months ago