$30 off During Our Annual Pro Sale. View Details »

CSE205 Lecture 08

CSE205 Lecture 08

Object-Oriented Programming and Data Structures
Interfaces
(202202)

Javier Gonzalez-Sanchez
PRO

September 18, 2021
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs
    CSE 205
    Object-Oriented Programming and
    Data Structures
    Lecture 08: Interfaces
    Dr. Javier Gonzalez-Sanchez
    [email protected]
    javiergs.engineering.asu.edu | javiergs.com
    PERALTA 230U
    Office Hours: By appointment

    View Slide

  2. jgs
    Previously …

    View Slide

  3. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 3
    jgs
    Abstract Classes
    § cannot be instantiated and contains one or more abstract methods (no
    definition body).
    § can contain methods
    § can contain data declarations

    View Slide

  4. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 4
    jgs
    Abstract Classes

    View Slide

  5. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 5
    jgs
    Abstract Methods
    § An abstract method is a method without a body.
    § It cannot be final or static because there is no definition, and it should be
    changed later.

    View Slide

  6. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 6
    jgs
    Abstract Methods

    View Slide

  7. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 7
    jgs
    Abstract Methods

    View Slide

  8. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 8
    jgs
    UML Class Diagram – abstract keyword

    View Slide

  9. jgs
    Interfaces

    View Slide

  10. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 10
    jgs
    Interfaces
    § Interfaces contains behaviors that a class implements.
    § An interface cannot be instantiated
    § An interface does not contain any constructors.
    § In an interface, all methods are abstract.
    § An interface cannot contain instance fields. The only fields that can appear in an
    interface must be declared both static and final.
    § An interface is not extended by a class; it is implemented by a class.
    § An interface can extend multiple interfaces.

    View Slide

  11. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 11
    jgs
    Interfaces

    View Slide

  12. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 12
    jgs
    Interfaces

    View Slide

  13. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 13
    jgs
    Interfaces

    View Slide

  14. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 14
    jgs
    Let’s Work

    View Slide

  15. jgs
    Polymorphism

    View Slide

  16. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 16
    jgs
    Polymorphism
    § A polymorphic reference is a reference variable that can refer to different
    types of objects at different points in time.
    § Polymorphic references are resolved at run-time, not during compilation.

    View Slide

  17. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 17
    jgs
    Abstract Methods

    View Slide

  18. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 18
    jgs
    Polymorphism

    View Slide

  19. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 19
    jgs
    Polymorphism

    View Slide

  20. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 20
    jgs
    Polymorphism

    View Slide

  21. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 21
    jgs
    Questions

    View Slide

  22. jgs
    CSE 205 Object-Oriented Programming and Data Structures
    Javier Gonzalez-Sanchez, Ph.D.
    [email protected]
    Fall 2021
    Copyright. These slides can only be used as study material for the class CSE205 at Arizona State University.
    They cannot be distributed or used for another purpose.

    View Slide