TAILIEUCHUNG - Object Oriented Programming - Lesson 5: Encapsulation, Overloading and Aggregation

Object Oriented Programming - Lesson 5: Encapsulation, Overloading and Aggregation includes Encapsulation (Visibility scope, Data hiding), Overloading (Principles, Constructor overloading), Aggregation (Principles, Order of initialization). | LESSON V. Encapsulation, Overloading and Aggregation Trinh Thanh TRUNG (MSc) trungtt@ Content • Encapsulation – Visibility scope – Data hiding • Overloading – Principles – Constructor overloading • Aggregation – Principles – Order of initialization • Class usage – Any classes – Java classes I. Encapsulation • Encapsulation: Prevents the code and data being randomly accessed by other code defined outside the class. – Group data and operations performed on these data together in a class – Hide details about the class implementation from the user. 4 1. Visibility scope (revisited) • Scope determines the visibility of program elements with respect to other program elements. • Given a class: – A private attribute or operation of an object is accessible by all others objects of the same class – A public attribute or operation of an object is accessible by all others objects. X getAuthorName private public Vu Thi Huong Giang Object outside the class Book Object MyBook If an attribute or operation is declared private, it cannot be accessed by anyone outside the class 5 2. Data hiding • A class provides data hiding – Data is in a unique scope; access controlled with public, private, protected keywords – Data is accessed through public methods; a collection of the signatures of public methods of a class is called interface. Avoid illegal modification of attributes Public .

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.