TAILIEUCHUNG - Lecture An introduction to Object-Oriented Programming with Java - Chapter 13: Inheritance and polymorphism

After you have read and studied this chapter, you should be able to: Write programs that are easily extensible and modifiable by applying polymorphism in program design; define reusable classes based on inheritance and abstract classes and abstract methods; define methods, using the protected modifier; parse strings, using a string tokenizer object. | Chapter 13 Inheritance and Polymorphism Chapter 13 Objectives After you have read and studied this chapter, you should be able to Write programs that are easily extensible and modifiable by applying polymorphism in program design. Define reusable classes based on inheritance and abstract classes and abstract methods. Define methods, using the protected modifier. Parse strings, using a String Tokenizer object. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance To explain the concept of inheritance, we will consider an example of a class roster. The class roster should contain both undergraduate and graduate students. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance Each student’s record will contain his or her name, three test scores, and the final course grade. The formula for determining the course grade is different for graduate students than for undergraduate students. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance There are two broad ways to design the classes to model undergraduate and graduate students. We can define two unrelated classes, one for undergraduates and one for graduates. We can model the two kinds of students by using classes that are related in an inheritance hierarchy. Two classes are unrelated if they are not connected in an inheritance relationship. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance If two objects are expected to share common behaviors and data, it is better to design their classes using inheritance. Using unrelated classes in such an instance will result in duplicating code common to both classes. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance For this example, we will design

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.