Introduction_Part_7

Introduction_Part_7 - Types of Method Overriding Generally methods of a subclass replace superclass methods An exception is constructor methods

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 Types of Method Overriding Generally methods of a subclass replace superclass methods. An exception is constructor methods, which do not replace, but refine superclass constructor methods. Thus invocation of a constructor method starts with the highest-level class, and proceeds down the hierarchy to the subclass of the object being instantiated. This is either accomplished implicitly, or explicitly with the super keyword.
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 Refinement Overriding public class Camera { private String cameraMake ; private String cameraModel ; Camera(String mk, String mdl) { //constructor cameraMake = mk; cameraModel = mdl; } public String make () { return cameraMake ; } public String model () { return cameraModel ; } } public class DigitalCamera extends Camera{ private int numPix ; DigitalCamera(String mk, String mdl, int n) { //constructor super (mk, mdl); numPix = n; } public int numberOfPixels
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_7 - Types of Method Overriding Generally methods of a subclass replace superclass methods An exception is constructor methods

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