tailieunhanh - Chapter 9 Polymorphism

.Polymorphism • Polymorphism is an object-oriented concept that allows us to create versatile software designs • Chapter 9 focuses on: defining polymorphism and its benefits using inheritance to create | Chapter 9 Polymorphism © 2004 Pearson Addison-Wesley. All rights reserved 9- Polymorphism Polymorphism is an object-oriented concept that allows us to create versatile software designs Chapter 9 focuses on: defining polymorphism and its benefits using inheritance to create polymorphic references using interfaces to create polymorphic references using polymorphism to implement sorting and searching algorithms © 2004 Pearson Addison-Wesley. All rights reserved 9- Outline Polymorphic References Polymorphism via Inheritance Polymorphism via Interfaces Sorting Searching © 2004 Pearson Addison-Wesley. All rights reserved 9- Binding Consider the following method invocation: (); At some point, this invocation is bound to the definition of the method that it invokes If this binding occurred at compile time, then that line of code would call the same method every time However, Java defers method binding until run time -- this is called dynamic binding or late binding Late . | Chapter 9 Polymorphism © 2004 Pearson Addison-Wesley. All rights reserved 9- Polymorphism Polymorphism is an object-oriented concept that allows us to create versatile software designs Chapter 9 focuses on: defining polymorphism and its benefits using inheritance to create polymorphic references using interfaces to create polymorphic references using polymorphism to implement sorting and searching algorithms © 2004 Pearson Addison-Wesley. All rights reserved 9- Outline Polymorphic References Polymorphism via Inheritance Polymorphism via Interfaces Sorting Searching © 2004 Pearson Addison-Wesley. All rights reserved 9- Binding Consider the following method invocation: (); At some point, this invocation is bound to the definition of the method that it invokes If this binding occurred at compile time, then that line of code would call the same method every time However, Java defers method binding until run time -- this is called dynamic binding or late binding Late binding provides flexibility in program design © 2004 Pearson Addison-Wesley. All rights reserved 9- Polymorphism The term polymorphism literally means "having many forms" A polymorphic reference is a variable that can refer to different types of objects at different points in time The method invoked through a polymorphic reference can change from one invocation to the next All object references in Java are potentially polymorphic © 2004 Pearson Addison-Wesley. All rights reserved 9- Polymorphism Suppose we create the following reference variable: Occupation job; Java allows this reference to point to an Occupation object, or to any object of any compatible type This compatibility can be established using inheritance or using interfaces Careful use of polymorphic references can lead to elegant, robust software designs © 2004 Pearson Addison-Wesley. All rights reserved 9- Outline Polymorphic References Polymorphism via Inheritance Polymorphism via Interfaces Sorting Searching

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.