4.14 Exercises


4.14 Exercises

  1. Explain the reason why a class is an appropriate decomposition unit. What other units are possible to consider?

  2. Explain why object-oriented programs need a control function such as main.

  3. The entire algorithm for a problem is decomposed into classes and functions. Explain this decomposition structure. Why is there a need to decompose a problem into subproblems?

  4. KJP programs do not allow public attribute definitions in classes. Explain the reason for this. What are the advantages and disadvantages? Hint: review the concepts of encapsulation and information hiding.

  5. The dynamic view of a program involves the objects of the problem collaborating to accomplish the overall solution to the problem. Where are these objects created and started? Explain.

  6. Consider the first complete program presented in this chapter. Add two more functions to class Ball. Include the corresponding function calls from class Mball. For example, add another attribute weight in class Ball. The additional functions would be get_weight and show_weight.

  7. Analyze the second KJP program presented in this chapter, which calculates the salary increase for employees. Follow the same pattern to write another program to compute the grade average per student. The data for each student is student name, grade1, grade2, grade3, and grade4.

  8. Restructure the second program, and convert it to an object-oriented program, similar to the first program presented.

  9. What are the main limitations of the programs with a single class and a single function? Explain.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net