DOC PREVIEW
UB CSE 115 - Polymorphism

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PolymorphismA Variable Declaration…Slide 3Subtype PolymorphismSlide 5ExamplesPolymorphismCSE 115 Spring 2006March 6, 8 & 10, 2006A Variable Declaration…Bird bird = new Duck();Can we do this?Only if Duck is a subclass of Bird or if Duck is a class that implements the Bird interface.A Variable Declaration…Bird bird = new Duck();Bird is the declared type of the variable birdDuck is the actual type of the variable birdSubtype PolymorphismObjects of the subclass can be provided to stand in for objects of the superclass.PolymorphismWhen there is a difference between the declared type and actual type of an object, the only methods that can be called are those that are declared in the declared type. The methods that get executed are those in the actual type.ExamplesFlyer-Bird-Duck-Penguin exampleBegan start/stop bouncing ball


View Full Document

UB CSE 115 - Polymorphism

Download Polymorphism
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Polymorphism and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Polymorphism 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?