TAILIEUCHUNG - Inheritance_Object-oriented programming

Outline: What is inheritance?, Inheritance in Java, Reuse. Readings: Java how to program, chapter 9. Similar things (sharing same set of attributes/operations): a group / a concept, Motorola A910 is a smartphone, Nokia E72 is a smartphone, Lenovo G450 is a laptop. | Inheritance Object-oriented programming Inheritance Đại học Công nghệ. ĐHQG Hà Nội Outline What is inheritance? Inheritance in Java Reuse Readings: Java how to program, chapter 9 Inheritance Đại học Công nghệ. ĐHQG Hà Nội "is-a" relationship Similar things (sharing same set of attributes/operations) a group / a concept Motorola A910 is a smartphone Nokia E72 is a smartphone Lenovo G450 is a laptop Similar groups (sharing a subset of attributes/operations) a bigger group / a more general concept A smartphone "is a" PDA (Personal Digital Assistant) A PDA "is a" computer A laptop "is a" computer An object of the subgroup "is-a" object of the supergroup Nokia E72 Motorola A910 Smartphone LenovoG450 Computer Laptop PDA Inheritance Đại học Công nghệ. ĐHQG Hà Nội Inheritance Based on "is-a" relationship Objects of subclass also belongs to superclass Subclass: more specialized, superclass: more general Subclass is derived or inherits from superclass hence, the terms 'derived class' and 'base class' In essence: Objects in the same class have the same set of attributes (different values though) and operations Objects of subclass have all members of superclass plus some more Objects of a subclass can also be treated as objects of its superclass Person name birthday getName() Employee name birthday getName() salary getSalary() Inheritance Đại học Công nghệ. ĐHQG Hà Nội Inheritance An Employee “is a” Person, apart from its own members, salary and getSalary, it also has name, birthday, getName() without having to declare them Employee is the subclass (derived) of Person Person is the superclass (base) of Employee Person - name: String - birthday: Date + getName(): String Employee - salary: double + getSalary(): double Arrow points from subclass to superclass Inheritance Inheritance tree can have many levels A Manager object inherits what an Employee has, including what a Person has. Inheritance Đại học Công nghệ. ĐHQG Hà

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.