Chapter 2 Flashcards
What is x after the following statements?
int x = 1;
x *= x + 1;
x is 2.
To assign a value 1 to variable x, you write
x = 1;
What is the exact output of the following code?
double area = 3.5;
System.out.print(“area”);
System.out.print(area);
area3.5
Suppose x is 1. What is x after x -= 1?
0
The __________ method returns a raised to the power of b.
Math.pow(a, b)
Suppose x is 1. What is x after x += 2?
3
___________ is the Java assignment operator.
=
Which of these data types requires the most amount of memory?
long
Which of the following is incorrect? int x = 9; long x = 9; float x = 1.0; double x = 1.0;
float x = 1.0;
What is x after the following statements?
int x = 2;
int y = 1;
x *= y + 1;
x is 4.
If you attempt to add an int, a byte, a long, and a double, the result will be a __________ value.
double
What is the value of (double)5/2?
2.5
According to Java naming convention, which of the following names can be variables? FindArea findArea totalLength TOTAL_LENGTH class
totalLength
Which of the following is a constant, according to Java naming conventions?
MAX_VALUE
Test
read
ReadInt
COUNT
MAX_VALUE
COUNT
-25 % 5 is _____
0