TAILIEUCHUNG - Inheritance and Polymorphism - ABC programming lesson

Inheritance and Polymorphism Welcome to the module Inheritance and Polymorphism. Inheritance is a process of creating a new class from an existing class. Inheritance allows you to inherit attributes and methods of the base class in the newly created class. Polymorphism is a feature of OOP that allows the data members of a class to behave differently based on their parameters and data types. In this module, you will learn about: Implementing Inheritance | Inheritance and Polymorphism ABC programming lesson Inheritance and Polymorphism Welcome to the module Inheritance and Polymorphism. Inheritance is a process of creating a new class from an existing class. Inheritance allows you to inherit attributes and methods of the base class in the newly created class. Polymorphism is a feature of OOP that allows the data members of a class to behave differently based on their parameters and data types. In this module, you will learn about: Implementing Inheritance Method Overriding Sealed Classes Polymorphism #1 - Implementing Inheritance Explain the concept of inheritance Describe how to implement inheritance in C#. State and explain the protected access modifier. State and explain the base keyword. State and explain the new keyword. Describe how to inherit constructors. Inheritance Inheritance specifies an “is a kind of" relationship Inheritance is a class relationship New classes specialize existing classes Musician Violin Player Base class Derived class Generalization Specialization Is this a good example of inheritance ? Purpose of Inheritance Reusability Reuse common methods and attributes among classes without recreating them. Use the same code in different applications with little or no changes. Generalisation Specialisation Extension Implementing Inheritance Just need to insert a colon after the name of the derived class followed by the name of the base class. The derived class can now inherit all non-private methods and attributes of the base class. Example of Inheritance Animal Cat "protected" Access Modifier Protected variables or methods are accessed only by: The class in which they are declared Derived class Specified using the protected keyword. "base" Keyword Like “super” in Java Access the variables and methods of the base class from the derived class. Cannot use the base keyword for invoking the static methods of the base class. Example of Using "base" Keyword "new" Keyword As a modifier to hide the methods

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.