Exposure Java Exercises -...

5
PreAPCS Exposure Java Exercises 05.05- 09 Date: Name: Period: 1. What is the simplest control structure? 2. Describe one-way selection. Questions 3 and 4 refer to program Java0507.java. 3. What is the output of this program if the user enters 800000? 4. What is the output of this program if the user enters 499999? 5. Write the Java statement that will do this action: If your grade is 70 or better, print "You passed!" 6. Why should indentation be used with control structures? 7. Look at program Java0508. Why does this program have strange output? 8. Look at program Java0509. How does this cure the problem of the previous program? 9. Describe two-way selection. 10. What statement is used with if for two-way selection? Exposure Java 2013, PreAPCS Edition Exercises 05.05-09 Page 1 05-22-13

Transcript of Exposure Java Exercises -...

Page 1: Exposure Java Exercises - SharpSchoolp5cdn2static.sharpschool.com/.../Server_12611/File/Exer…  · Web viewExposure Java 2013, PreAPCS Edition Exercises 05 ... Each of the possible

PreAPCS Exposure Java Exercises 05.05- 09 Date:Name: Period:1. What is the simplest control structure?

2. Describe one-way selection.

Questions 3 and 4 refer to program Java0507.java.3. What is the output of this program if the user enters 800000?

4. What is the output of this program if the user enters 499999?

5. Write the Java statement that will do this action: If your grade is 70 or better, print "You passed!"

6. Why should indentation be used with control structures?

7. Look at program Java0508. Why does this program have strange output?

8. Look at program Java0509. How does this cure the problem of the previous program?

9. Describe two-way selection.

10. What statement is used with if for two-way selection?

Questions 11 and 12 refer to program Java0510.java.11. What is the output of this program if the user enters 1600?

12. What is the output of this program if the user enters 400?

13. Write the Java statement that will do this action: If your grade is 70 or better, print "You passed!"

Exposure Java 2013, PreAPCS Edition Exercises 05.05-09 Page 1 05-22-13

Page 2: Exposure Java Exercises - SharpSchoolp5cdn2static.sharpschool.com/.../Server_12611/File/Exer…  · Web viewExposure Java 2013, PreAPCS Edition Exercises 05 ... Each of the possible

otherwise print "You failed!"

14. Describe Multiple-Way Selection.

15. Does Multiple-Way Selection use a conditional statement?

16. What command is used for multi-way selection?

17. Which data types work with switch?

18. Which data types do not work with switch?

19. With switch there are usually at least _______ possible outcomes.

20. Refer to the previous question.Each of the possible outcomes starts with what reserved word?

21. The output of program Java0512.java looks very strange. How does Java0513.java cure this problem?

22. When will the program execute the default case?

23. Does the default case need a break command? Why or Why not?

24. Can the cases in a switch structure have multiple statements?

Questions 25 through 28 refer to program Java0514.java.25. What is the output of this program if the user enters 'A'?

26. What is the output of this program if the user enters 'Q'?

27. What is the output of this program if the user enters 'b'?

Exposure Java 2013, PreAPCS Edition Exercises 05.05-09 Page 2 05-22-13

Page 3: Exposure Java Exercises - SharpSchoolp5cdn2static.sharpschool.com/.../Server_12611/File/Exer…  · Web viewExposure Java 2013, PreAPCS Edition Exercises 05 ... Each of the possible

28. Explain how program Java0515.java is more flexible than Java0514.java.

Questions 29 through 32 refer to program Java0517.java.29. What is the output of this program if the user enters 4?

30. What is the output of this program if the user enters 6?

31. What is the output of this program if the user enters 12?

32. What is the output of this program if the user enters 18?

Questions 33 and 34 refer to program Java0519.java.33. What is the output of this program if the user enters Remy?

34. What is the output of this program if the user enters Blake?

35. What are 2 synonyms for Repetition?

36. What loop structure is used with fixed repetition?

37. In fixed repetition, what does fixed mean?

38. What would you need to change in program Java0520 if Joe wanted the message displayed 1000 times?

39. What would you need to change in program Java0521 if Joe wanted the message displayed 1000 times?

40. What does LCV stand for?

Use this statement for questions 41-46: for(int j = 1; j <= 100; j++)

41. What does the int j = 1 mean?

42. What does the j <= 100 mean?

43. What does the j++ mean?

Exposure Java 2013, PreAPCS Edition Exercises 05.05-09 Page 3 05-22-13

Page 4: Exposure Java Exercises - SharpSchoolp5cdn2static.sharpschool.com/.../Server_12611/File/Exer…  · Web viewExposure Java 2013, PreAPCS Edition Exercises 05 ... Each of the possible

44. Rewrite the for loop heading so it counts from 0 to 100 by 2s.

45. Rewrite the for loop heading so it counts from 0.25 to 2.75 by 0.25s.

46. Rewrite the for loop heading so it counts from 100 backwards down to 1, by 1s.

47. Besides int and double, what other data type can be used as a for loop counter?

48. Look at program Java0525. The program’s output is very strange. What causes this?

49. What kind of loop is the while loop?

50. Look at program Java0526. How does this program cure the problem of the previous program?

51. The for loop has 3 things between the parentheses in the heading. List them.

52. Refer to the previous question.What is the only thing between the parentheses in the heading of a while loop.

53. Refer to the previous 2 questions. If the while loop only has 1 of these 3 things in its heading, where do the other 2 go?

54. In computer science, what is a flag?

Exposure Java 2013, PreAPCS Edition Exercises 05.05-09 Page 4 05-22-13