JAVA Basic OOP Principles 3 1 Encapsulation Inheritance
JAVA – Basic OOP Principles Εβδομάδα Νο. 3 1
Σημερινό μάθημα Ενθυλάκωση (Encapsulation) Κληρονομικότητα (Inheritance) super/this keywords Πολυμορφισμός (Polymorphism) method overriding Ασκήσεις 2
Κληρονομικότητα – Inheritance (2/4) Bicycle Υπερκλάση των κλάσεων Mountain Bike, Road Bike και Tandem Bike Mountain Bike Υποκλάση της κλάσης Bicycle Road Bike Υποκλάση της κλάσης Bicycle Tandem Bike Υποκλάση της κλάσης Bicycle 5
Κληρονομικότητα – Inheritance (3/4) Bicycle Mountain Bike extends … extends Road Bike … Tandem Bike extends … 6
Κληρονομικότητα – Inheritance (4/4) Αφού το Mountain. Bike κληρονομεί από ένα Bicycle, τότε το Mountain. Bike είναι τύπου: Mountain. Bike Bicycle 7
Χρήσιμα Links The Java Tutorials - Trail: Learning the Java Language Lesson: Object-Oriented Programming Concepts What Is Inheritance? http: //download. oracle. com/javase/tutorial/java/concepts/index. html “Object-Oriented Programming Concepts teaches you the core concepts behind objectoriented programming: objects, messages, classes, and inheritance. This lesson ends by showing you how these concepts translate into code. Feel free to skip this lesson if you are already familiar with object-oriented programming. ” The Java Tutorials - Trail: Learning the Java Language Lesson: Interface and Inheritance http: //download. oracle. com/javase/tutorial/java/Iand. I/subclasses. html “This section describes the way in which you can derive one class from another. That is, how a subclass can inherit fields and methods from a superclass. You will learn that all classes are derived from the Object class, and how to modify the methods that a subclass inherits from superclasses. ” 12
Επόμενο μάθημα Interfaces Αφηρημένες κλάσεις / μέθοδοι (Abstract classes/methods) Packages UML – Class Diagrams 13
Τέλος διαφανειών See you next time! The end 14
- Slides: 14