Sams Teach Yourself C in 21 Days

(singke) #1
Working with Java Classes and Methods 741

BD5


AAlthough overloaded methods do have the same name, they must differ in the num-
ber and/or data type of their arguments. When a program calls an overloaded
method, Java can tell which one to call based on the number and type of arguments
passed.
Q How are Java methods different from functions in C and C++?
AThere are no important differences between Java methods and C/C++ functions.
However in Java a method must be inside a class.

Workshop ............................................................................................................


The Workshop provides quiz questions to help you solidify your understanding of the
material covered, and exercises to provide you with experience in using what you’ve
learned. Answers to the quiz are provided in Appendix F.

Quiz ..............................................................................................................



  1. What name should you assign to a class constructor method?

  2. When and where would you use the extendskeyword?

  3. Do all Java methods return a value to the caller?

  4. Can a class constructor be overloaded?

  5. When is a constructor method called?

  6. Can you use any Java class as the parent class for inheritance?

  7. What Java keyword is used to prevent a class from being inherited?

  8. Can an object be created from an abstract class?


40 448201x-Bonus5 8/13/02 11:23 AM Page 741

Free download pdf