Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE205 Lecture 07a

CSE205 Lecture 07a

Object-Oriented Programming and Data Structures
Polymorphism
(202109)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez
PRO

September 17, 2021
Tweet

Transcript

  1. jgs CSE 205 Object-Oriented Programming and Data Structures Lecture 07:

    Polymorphism Dr. Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 2 jgs

    Homework 01 § See description on Canvas. It is all about inheritance, abstract (class and method), and polymorphism. § Due date: Sep 21 at 1:29 PM You have a week to accommodate to your needs, but you do not need a full week to complete it. No extensions
  3. jgs Previously…

  4. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 4 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.
  5. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 5 jgs

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

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

    Interfaces
  8. jgs Notes Java Programming for Assignment 01 (

  9. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 9 jgs

    The toString Method
  10. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 10 jgs

    The toString Method § The toString method is a method that takes no parameter and returns a string § A returned string usually contains information on instance variables of its class. § Each class has a default toString method that contains its class object name and hash number. § When an object is used with System.out.println method, its toString method will be called.
  11. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 11 jgs

    The toString Method
  12. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 12 jgs

    java.Util.Scanner
  13. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 13 jgs

    UML Class Diagram – abstract keyword
  14. jgs Notes Java Programming for Assignment 01 )

  15. jgs Polymorphism

  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.
  17. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 17 jgs

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

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

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

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

    Test Yourselves § Adding elements § Searching for elements § List all elements
  22. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 22 jgs

    Questions
  23. jgs CSE 205 Object-Oriented Programming and Data Structures Javier Gonzalez-Sanchez,

    Ph.D. javiergs@asu.edu 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.