Overloading overriding runtime type and object orientation (1)(1).txt
×÷Õߣºjeru email: jeru@ ÈÕÆÚ£º7/3/2001 10:01:58 AM 6)Overloading overriding runtime type and object orientation Objective 1) State the benefits of encapsulation in object oriented design and write code that implements tightly encapsulated classes and the relationships "is a" and "has a". Encapsulation involves hiding data of a class and allowing access only through a public interface. The separation of interface and implementation makes it easier to modify the code within a class without breaking any other code that uses it. encapsulation, inheritance, polymorphism are three principal characteristics of Object Oriented programming. Implementing OO relationships ¡¤ ¡°is a¡± relationship is implemented by inheritance (extends keyword) ¡¤ ¡°has a¡± relationship is implemented by providing the class with member variables. Overloading and Overriding ¡¤ Overloading is an example of polymorphism. (operational / parametric) ¡¤ Overriding is an example of runtime polymorphism (inclusive) ¡¤ A method can have the same name as another method in the same class, provided it forms either a valid overload or override Objective 2) Write code to invoke overridden or overloaded methods and parental or overloaded constructors; and describe the effect of invoking these methods. Overloading Overriding Signature has to be different. Just a difference in return type is not enough.
Overloading overriding runtime type and object orientation (1)(1) 来自淘豆网m.daumloan.com转载请标明出处.