Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
APCS Exposure Java Name: KEY Exercises 06.06-10 Date: Period: 1. What statement must be at the top of your program in order for you to use the DecimalFormat class? import java.text.DecimalFormat 2. Look at program Java0616.java. What do the 5 zeros mean? Fill in leading zeros in front of the output number 3. Refer to the previous question. What happens if the number being displayed has more than 5 digits? Output formatting is ignored 4. Print the Java code necessary to create a DecimalFormat object called output that will that will display an integer like 1234567 as 1,234,567 DecimalFormat output = new DecimalFormat("0,000,000"); 5. Print the Java code necessary to create a DecimalFormat object called output that will that will display a real number like 12.34567 as $12.35 DecimalFormat output = new DecimalFormat("$0.00"); 6. Print the Java code necessary to create a DecimalFormat object called output that will that will display a real numbers rounded to 3 decimal places. DecimalFormat output3 = new DecimalFormat("0.000"); 7. How many different shades of Red, Green, and Blue are possible? (Hint: Look at program Java0621.java.) 255 8. In the statement: Bank tom = new Bank(2000); What is Bank and what is Tom? Bank is a class and tom is an object 9. What kind of object is created by this statement: g.setColor(new Color(255,0,255)); A new color object that will set the color to purple 10. Refer to the previous question. Are the same type of objects used in program Java0622.java ? No, there are three different objects 11. What are the 3 steps in creating a Polygon in Java? Create a Polygon object. Add coordinate points to the Polygon object Use the Polygon object in a drawPolygon or fillPolygon method call 12. Look at program Java0623.java. What do you need to do to this program to make the output a hexagon? Add one more coordinate point 13. When creating a Polygon, does the order in which you add the coordinate points matter? Yes Exposure Java 2013, APCS Edition Exercises 06.06-10 Page 1 05-23-13 Refer to program Java0625.java for questions 14 through 16. 14. How would you change this program to display 500 random lines? Alter the value in the for condition to 500 15. What would happen is the 2 800s are changed to 400s? The lines become shorter and will draw on the left side of the screen 16. What would happen is the 2 600s are changed to 300s? The lines become shorter and will draw on the top half of the screen 17. What Scanner method is used to enter a String? nextLine 18. What Scanner method is used to enter an int? nextInt 19. What Scanner method is used to enter a double? nextDouble 20. Look at program Java0630.java. What is wrong with this program? Not all input appears to be entered properly 21. Look at program Java0631.java. How does this program cure the problem of program Java0630.java? The dummy variable absorbs the return character to allow the next input to work correctly. 22. Look at program Java0632.java. How does this program cure the problem of program Java0630.java? Separate Scanner objects are created for text and numerical input. 23. What is a wrapper class? A wrapper class creates objects capable of storing primitive data values like int and doubles. 24. What is the difference between int and Integer? int is a simple data type. Integer is a class. 25. What is the difference between double and Double? double is a simple data type. Double is a class. 26. Which methods will convert Integer and Double objects back to simple data types? intValue and doubleValue 27. What attributes of the Integer class store the largest and smallest possible int values? MAX_VALUE & MIN_VALUE 28. What are the largest and smallest possible int values? 214748367 & -214748368 Exposure Java 2013, APCS Edition Exercises 06.06-10 Page 2 05-23-13