5.11 Exercises


5.11 Exercises

  1. Explain the reason why a function is a complete decomposition unit. What is the purpose of a function?

  2. Explain why function main is a special function.

  3. Why is it necessary to carry out data transfer among functions? How is this accomplished?

  4. Design and write a function definition in KJP that includes two parameters and returns a value.

  5. Explain the reason why more than one initializer function (constructor) is normally necessary in class.

  6. In the complete program presented in this chapter, add two attributes, salary and address, and two or more functions to class Person. Include the corresponding function calls from class Mperson.

  7. Modify the program that computes the salary increase of employees presented in Chapter 4. Design and write two classes, Employee and Memployee. All the computations should be done in class Employee, and function main should be defined in class Memployee.

  8. Design and write a program that consists of three classes: Person, Ball, and Mperson. An object of class Person interacts with two objects of class Ball, as briefly explained in Chapter 3. Redesign of these classes is needed.




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