PreAPCS Exposure Java / Exercises 07.04- 06 / Date:
Name: / Period:

1. Void methods are called as ______program statements.

2. What do return methods always do?

3. A return method call must be ______, which uses the value that is returned by the method.

4. Is the main method a void method or a return method?

5. Look at program Java0715.java.

Write the code for a 5th method called remainder which will compute and display the integer remainder of n1 divided by n2.

6. List 2 differences between void and return methods. (Hint: Look at program Java0716.java.)

7. Refer to question #5 and look at program Java0717.java.

Rewrite the remainder method as a return method.

8. Case studies help to explain computer science concepts by presenting a ______.

9. Does the Java compiler care about Program Design?

10. Look at program Java0718.java. This program does compile and does execute.

What is wrong with this program?

11. Look at program Java0719.java. How is this an improvement from Java0718.java?

12. What is still wrong with program Java0719.java?

13. Look at program Java0720.java. How is this an improvement from Java0719.java?

14. Look at program Java0721.java. How is this an improvement from Java0720.java?

15. Do any of the first 4 Payroll Case Study programs satisfy the fundamental design principles

of Object Oriented Programming?

16. Look at program Java0722.java. This program is broken up into different methods which is

better design. Why does it not compile?

17. Look at program Java0723.java. This program fixed the problem from Java0722.java by defining the variables in different locations. Where are most of the variables defined?

18. Look again at program Java0723.java. One variable, the DecimalFormat object money is defined as a local variable inside the printCheck method. Why is it defined here and not as a class variable with all of the rest?

19. Refer to the previous question. Why is it that the rest of the variables have to be declared as

class variables?

20. Look at program Java0724.java. How is this different from program Java0723.java?

21. What method is contained in the driving class? (Hint: Look at program Java0724.java.)

22. Class variables are also called what?

23. What is a local variable?

24. Where are local variables accessible?

25. What are class variables?

26. Where are class variables accessible?

27. When should a variable be declared as a local variable?

28. When should a variable be declared as a class variable?

29. Programs should use ______identifiers.

30. Control structures and block structure need to use a ______indentation style.

31. Specific tasks should be placed in modules called ______.

32. Similar methods accessing the same data should be placed in a ______.

33. What should the main method be used for?

34. Can one method be used to create another method?

35. Look at programs Java0727.java.

Give 2 examples of how this program confirms your answer to the previous question.

36. How many lines of code are in a modern video game?

Exposure Java 2013, PreAPCS Edition Exercises 07.04-06 Page 3 05-22-13