Conversion and Constants

advertisement
Name: Enter name here
Period: Enter period here
Conversion and Constants
1. What does Java check before a value is stored in a variable?
Answer here
2. Explain the difference between a widening conversion, and a narrowing conversion.
Answer here
3. Which is the largest Primitive Data Type?
Choose an item.
4. Which is the smallest Primitive Data Type?
Choose an item.
5. Is this an example of a widening or a narrowing conversion?
double x;
int y = 10;
x = y;
Answer here
6. What do you need to do whenever you narrow convert?
Answer here
7. In the following code, what is the final value of piesPerPerson, and why?
Int pies = 10, people = 4;
Double piesPerPerson;
piePerPerson = (double) pies / people;
Answer here
8. In the following code, what is the final value of piesPerPerson, and why?
Int pies = 10, people = 4;
Double piesPerPerson;
piePerPerson = (double)(pies / people);
Answer here
9. Why does the following code produce an error?
short x = 5, y = 7;
short z = x + y;
Answer here
10. In Java, what do we call a variable that is read-only and cannot be changed?
Answer here
11. What keyword do we put in front of a variable name to make it a constant?
Answer here
12. What is a good suggestion to follow when naming constants?
Answer here
13. Give an example of a constant that is already declared and ready to use:
Answer here
Download