The following code fragment reads in two numbers:
Scanner input = new Scanner(System.in);
int i = input.nextInt();
double d = input.nextDouble();
What are the correct ways to enter these two numbers?
A. Enter an integer, a space, a double value, and then the Enter key.
B. Enter an integer, two spaces, a double value, and then the Enter key.
C. Enter an integer, an Enter key, a double value, and then the Enter key.
D. Enter a numeric value with a decimal point, a space, an integer, and then the Enter key. - Answers A.
Enter an integer, a space, a double value, and then the Enter key.
B. Enter an integer, two spaces, a double value, and then the Enter key.
C. Enter an integer, an Enter key, a double value, and then the Enter key.
Which of the following is a valid identifier?
A. $343
B. class
C. 9X
, D. 8+9
E. radius - Answers A. $343
E. radius
To improve readability and maintainability, you should declare _________ instead of using literal values
such as 3.14159.
A. variables
B. methods
C. constants
D. classes - Answers C. constants
If a number is too large to be stored in a variable of the float type, it _____________.
A. causes overflow
B. causes underflow
C. causes no error
D. cannot happen in Java - Answers A. causes overflow
-24 % -5 is _____
A. 3
B. -3
C. 4
D. -4
E. 0 - Answers D. -4
Math.pow(2, 3) returns __________.
A. 9