Introduction_Part_8

Introduction_Part_8 - Polymorphism Polymorphism = many...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated: January 5, 2012 CSE 2011 Prof. J. Elder Polymorphism Polymorphism = “many forms” Polymorphism allows an object variable to take different forms, depending upon the specific class of the object it refers to. Suppose an object o is defined to be of class S . It is now valid to instantiate o as an object of any type T that extends S . Thus o can potentially refer to a broad variety of objects.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last Updated: January 5, 2012 CSE 2011 Prof. J. Elder Replacement Overriding public class DigitalCamera extends Camera{ private int numPix ; DigitalCamera(String mk, String mdl, int n) { //constructor super (mk, mdl); numPix = n; } public int numberOfPixels () { return numPix ; } public byte [][][] getDigitalImage () { return takeDigitalPhoto(); } } public class AutoDigitalCamera extends DigitalCamera{ AutoDigitalCamera(String mk, String mdl, int n) { //constructor super (mk, mdl, n); } public byte[][][] getDigitalImage () { autoFocus() ; return takeDigitalPhoto();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Page1 / 5

Introduction_Part_8 - Polymorphism Polymorphism = many...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online