Slides0220 - COP 3330 Slides 2/20 Topics The super keyword...

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

View Full Document Right Arrow Icon
Slides 2/20 COP 3330
Background image of page 1

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

View Full DocumentRight Arrow Icon
Topics The super keyword Abstract classes Final classes and methods
Background image of page 2
Constructors Every constructor MUST begin with the construction of an object of the superclass Sometimes it’s implicit (example: every constructor you’ve ever seen so far in this course) Sometimes it’s explicit using the super keyword
Background image of page 3

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

View Full DocumentRight Arrow Icon
The super Keyword super refers to the parent class The meaning is somewhat overloaded Use in a constructor - If you choose to explicitly construct the parent object use super - Example: public Car(Motor m){ super(m); ...
Background image of page 4
The super Keyword Use anywhere else - super is very similar to this , except that it’s treated as an object of the superclass - Example: Consider Point3D extended from Point and suppose Point has a magnitude method public double magnitude(){ //In Point3D double mag2D = super.magnitude(); return Math.sqrt(mag2D * mag2D + z * z); }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Abstract Classes Abstract classes are part way between an interface and class
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Slides0220 - COP 3330 Slides 2/20 Topics The super keyword...

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

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