PreAPCS Exposure Java Exercises 07.01- 03 Date: Name: Period:

1. What are the 2 data fields of the Math class?

2. If you want to call a class method, what do you need to use?

3. If you want to call an object method, what must be created?

4. In the statement int num; int is the ______and num is the ______.

5. In the statement Bank tom; Bank is the ______and tom is the ______.

6. What phrase means the same thing as simple data types?

7. List 3 simple data types.

8. How many values can a simple data type store?

9. What 2 things can objects store?

10. ______provide information to methods for processing.

11. Methods fall into two major categories, what are they?

12. What kind of values do void methods return?

13. Which of the following is true? (a) A method can be BOTH a void method and a class method. (b) A method can be BOTH a void method and a object method. (c) A method can be BOTH a return method and a class method. (d) A method can be BOTH a return method and a object method. (e) All of the above

14. It is not possible to create large, reliable programs without being very conscious of ______.

Exposure Java 2013, PreAPCS Edition Exercises 07.01-03 Page 1 02-12-13 15. What is modular programming?

16. What are subroutines called in Java?

17. Can a program have other “secondary” methods besides the main or paint methods?

18. Explain the class-dot-method format for calling methods.

19. What is the class identifier?

20. What is the method identifier?

21. What is the difference between calling methods that you have created yourself and calling other methods?

22. Assume the existence of a Greetings class which contains a method called hello. Write necessary Java code to call the hello method.

23. List 3 things required by a user-defined method.

24. Compare programs Java0702.java and Java0703.java. Both programs have the same fullName, Street, and cityStateZip methods. The first program called the methods using the class-dot-method format. The second program calls the methods just by using the method name. How does this work if the name of the class is not specified?

25. Compare programs Java0703.java and Java0704.java. Both programs have identical main methods which call 3 other methods using only the method identifiers. The first program works. Why does the second program not compile?

26. Compare programs Java0704.java and Java0705.java. How does the second program cure the problem of the first?

Exposure Java 2013, PreAPCS Edition Exercises 07.01-03 Page 2 02-12-13 27. When is using the class identifier optional?

28. When is using the class identifier required?

29. If a program has more than one class, which class is the primary class?

30. If a program has more than one class, which class is declared public?

31. What Applet method controls the graphics display of an Applet in the same manner that the main method controls the sequence in an application program?

32. Look at program Java0706.java. Explain why this program is said to have “poor program design”.

33. In an application, is it considered poor design to put all of the program statements in the main method?

34. Are parameters necessary for all methods, or just the majorty of them?

35. What should the main method or the paint method look like in a well-desgined program?

36. Graphical output to an applet window requires the use of a ______object.

37. Any method that needs to display graphical output requires what?

38. If you choose to break up a large graphics program into multiple methods, you need to make sure that you ______to ALL of these methods.

39. According to Object Oriented Design, common methods should be placed in their own ______.

40. In a program with multiple classes, which is the driving class?

41. Compare the paint methods of Java0707.java and Java0708.java. In the second program, why are all of the method calls preceded with “House.”?

42. Refer to the previous question. Why was this not necessary in the first program?

Exposure Java 2013, PreAPCS Edition Exercises 07.01-03 Page 3 02-12-13 43. The key difference between creating parameter methods and non-parameter methods is the ______.

44. All method declarations have an identifier followed by ______.

45. What is the difference between an actual parameter and a formal parameter?

46. Information is passed from the ______to the ______.

47. An actual parameter can be several different things. List 5 examples.

48. Does parameter sequence matter?

49. Look at program Java0713.java. What is wrong with Line 1?

50. Look again at program Java0713.java. What is wrong with Line 2?

51. If a method has several parameters, do they all need to be of the same type?

52. Can the actual parameter identifiers be the same as the formal parameter identifiers?

53. Can the actual parameter identifiers be the different from the formal parameter identifiers?

54. List 4 important rules for using methods with parameters.

Exposure Java 2013, PreAPCS Edition Exercises 07.01-03 Page 4 02-12-13