excercises 4.01-04
26. What is the output of System.out.println(Math.sqrt(100)); ?
10
37. What is the output of System.out.println(Math.max(100,50)); ?
100
38. What is the output of System.out.println(Math.min(100,50)); ?
50
41. What is the output of System.out.println(Math.pow(4,3)); ?
64
39. What is the output of System.out.println(Math.abs(-7)); ?
7
40. What is the output of System.out.println(Math.pow(3,4)); ?
81
29. Refer yet again to question 26. What does 100 signify?
Argument or parameter
32. The information, which is passed to a method is called an _____________ or a _____________.
Argument or paramter
19. What is encapsulation?
Attributes and methods are package in the same container object or capsule.
33. Where are parameters placed?
Between parentheses following the method identifer
2. What is the difference between C++ and Java with regards to OOP?
C++ can be used without using oop but java revolves around oop
27. Refer to the previous question. What does Math signify?
Class identifier contains the method
5. Why did the first stage of program design not last long?
Computers became cheaper and programmers were more expensive and programs required frequent updating and debugging
34. What 4 things can parameters be?
Constants variables expressions or methods
13. Structured programming greatly improved the _____________, _____________, and _____________, of programs.
Creation,debugging and updating
3. What are the 4 stages of program design?
Cryptic programming stage Unstructured, spaghetti-programming stage Structured programming stage Object oriented programming stage.
24. What 2 things do classes contain?
Data or attributes
15. OOP incorporates what 3 features?
Encapsulation, class interaction and polymorphism
21. Explain class interaction in computer science terms.
Existing classes work together by interacting with each other and new classes.
42. Are PI and E attributes or methods of the Math class?
Final attributes
. The floor, ceil, and round methods of the Math class all "round" in some way. What is the difference among them?
Floor returns next lowest whole number Ceil returns next higher whole number Round method is traditional rounding approach
6. What quick fix statement was used in the 2nd stage of program design?
Goto statement
14. Why are computer programs so much longer today that they were in the late 1980s and early 1990s?
Incredible amount of complexity in today's programs
22. What are 2 types of class interaction?
Inheritance and composition
20. What does the word polymorphism mean?
Many forms
28. Refer again to question 26. What does sqrt signify?
Method identifier
35. What is the output of System.out.println(Math.sqrt(-100)); ?
NaN
9. Is GOTO used in structured programming?
No because it was a major drawback to reliability
1. What does OOP stand for?
Object oriented programming
10. In structured programming, program flow is strictly controlled with how many entrances and exits?
One entrance and one exit
12. In structured programming, how many tasks per module?
One task one module
7. Refer to the previous question. How did this statement lead to the term spaghetti programming?
People unfamiliar with design of such programs would draw program flows which crossed line and looked like spaghetti
17. In OOP, what are methods used for?
Perform some actions on the information
18. What 2 Java methods have you already learned about?
Print and println
8. Programs in the past and today have one common goal that allows no compromise. What is that?
Reliability
16. In OOP, what are attributes used for?
Store program information
4. Why were some programs intentionally written very cryptic in the 1st stage of program design?
To assist with security and stoked egos for the programmer
30. What is a parameter used for?
Used to provide necessary info to a method
23. Modules that perform a related set of functions are grouped together in a special program type of container. What is this container called?
class
25. What are the 2 types of methods in Java?
class methods and object methods
11. In structured programming, program statements with a common purpose were grouped together in special _____________.
modules
31. Can a method be an argument for another method?
yes