{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture21-Objects4

lecture21-Objects4 - Lecture 21 Inheritance and...

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

View Full Document Right Arrow Icon
Lecture 21: Inheritance and Polymorphism CS 170, Section 000 12 November 2009 11/12/2009 CS170, Section 000, Fall 2009 1
Background image of page 1

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

View Full Document Right Arrow Icon
Lecture Plan Logistics ¾ More on Inheritance: ¾ constructor chaining, casting, more examples ¾ Polymorphism CS170, Section 000, Fall 2009 2
Background image of page 2
Logistics Homework 1-5: solutions posted Labs 1-10: solutions posted HW6 : solution to be posted by tomorrow (Fri) Midt 2 T d N 17 th Midterm 2: Tuesday, Nov 17 ¾ Review Session: Monday Nov 16, 4:15-6pm, W301 ¾ Practice exam: will try to circulate by tomorrow (Fri) 11/16/2009 CS170, Section 000, Fall 2009 3
Background image of page 3

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

View Full Document Right Arrow Icon
Inheritance – basic idea GeometricObject color isFilled Triangle Circle Rectangle sideLength radius width height 4
Background image of page 4
Superclasses and Subclasses GeometricObject1.java Circle4.java Rectangle1 ja a Rectangle1.java 5
Background image of page 5

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

View Full Document Right Arrow Icon
Inheritance A subclass inherits all fields and methods from the l superclass A subclass can also: Add new fields Add new methods id h h d f h l Override the methods of the superclass Superclass’s constructor are not inherited Unlike fields and methods h k d l l l l They are invoked explicitly or implicitly 6
Background image of page 6
Using the Keyword super super refers to the superclass of the class in which super appears This keyword can be used in few ways: To call a superclass constructor To call a superclass method To access a superclass public data field 7
Background image of page 7

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

View Full Document Right Arrow Icon