What is the output of the following code?public class Solution { public static void main(String args[]) { double x = 79.85; System.out.println(Math.round(x)); } } Options: Pick one correct answer from below798079.8None of the above
Question
What is the output of the following code?public class Solution { public static void main(String args[]) { double x = 79.85; System.out.println(Math.round(x)); } } Options: Pick one correct answer from below798079.8None of the above
Solution
The output of the code will be 80. The Math.round() function in Java rounds a decimal number to the nearest whole number. Since 79.85 is closer to 80 than 79, it will be rounded up to 80.
Similar Questions
Select the correct answerWhat will be the output of the following Java program?class Output { public static void main(String args[]) { double ct1 = 3.0; double ct2 = 2.0; double ct3 = Math.pow( ct1, ct2 ); System.out.print(ct3); } }Options3.02.09.08.0
Select the correct answerWhat will be the output of the following Java statement?class output { public static void main(String args[]) { double ct1, ct2, ct3; ct1 = 3.0/0; ct2 = 0/4.0; ct3 = 0/0.0; System.out.println(ct1); System.out.println(ct2); System.out.println(ct3); } }Options0.0InfinityNaNall of the mentioned
What is the output of the following code?public class Solution { public static void main(String args[]) { int x = 7--2; System.out.println(x); }}
What is the output of the above program?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } }02.0Compile time error None of the above
elect the correct answerWhat is the output of the following program?public class Score{ public static void main(String[] args) { double data = 222.423; int sum = 3; float value = 2.1f; System.out.println(data + sum + value); }}Options227.52299222222.423222.5
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.