Which one is a valid statement in Java?I. double num = 2.718;II. double num = @718;III. double num = 2#7_1_8;
Question
Which one is a valid statement in Java?I. double num = 2.718;II. double num = @718;III. double num = 2#7_1_8;
Solution
The valid statement in Java is:
I. double num = 2.718;
The other two statements are invalid in Java.
II. double num = @718; is invalid because '@' is not a valid character in a number.
III. double num = 2#7_1_8; is invalid because '#' is not a valid character in a number and underscores are not allowed at the beginning of a number after a decimal point.
Similar Questions
which of the following declarations is INCORRECT?A. String s = "Hi!";B. int[] ar = new int(3);C. double d = 1.3E + 21;D. double d = 1.3D;
Which of the following can be used to declare a floating-point variable in Java?floatdoubleBoth float and doubleNeither float nor doub
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
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
Which of the following are legal lines of Java code? 1. int ct1 = (int)888.8; 2. byte ct2 = (byte)100L; 3. long ct3 = (byte)100; 4. byte ct4 = (byte)100L;Options2 and 31 and 23 and 4All statements are correct
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.